php - Code never executed, not getting any errors -


i trying use ajax , html5 handle file uploads clients computer folder on server.

right alert message below in addition success function never executed , not sure why. not getting js errors. both php script , folder save file granted full read/write permissions.

it extremely difficult me work without seeing errors.

i appreciate assistance in identifying cause of problem, , getting errors or @ least alert message execute.

many in advance!

jquery

    $.ajax({         url: 'upload.php',  //server script process data         type: 'post',         xhr: function() {  // custom xhr             myxhr = $.ajaxsettings.xhr();             if(myxhr.upload){ // check if upload property exists                 myxhr.upload.addeventlistener('progress',progresshandlingfunction, false); // handling progress of upload             }             return myxhr;         },         //ajax events         success: function(data){             alert("ok");             $('body').html(data);         },         // form data         data: formdata,         //options tell jquery not process data or worry content-type         cache: false,         contenttype: false,         processdata: false      }); 

html

    <form enctype="multipart/form-data">     <input name="file" type="file" />     <input type="button" value="upload" />     </form>     <progress></progress> 

upload.php

<?php if ($_files["file"]["name"] != null) {   if (file_exists("uploads/" . $_files["file"]["name"]))     echo $_files["file"]["name"] . " exists. ";   else     move_uploaded_file($_files["file"]["tmp_name"], "uploads/" . $_files["file"]["name"]); }   ?> 

add error handler well.

$.ajax({   success: function(data){     console.log("ok");     $('body').html(data);   },   error: function(xhr, textstatus, errorthrown){     console.log('an error has occurred!');     console.log(textstatus);     console.log(errorthrown);   } }); 

javascript won't throw errors failed ajax request, need catch them yourself.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -