php - Phonegap image upload fail to upload -
i follow this tutorial uploading images server using phonegap. data gets sent server fails upload. response when try upload picture server.
here php code
<?php header("access-control-allow-origin: *"); print_r($_files); $new_image_name = "image.jpg"; move_uploaded_file($_files["file"]["tmp_name"], "/products/".$new_image_name); ?>
and here function run whole thing on app
function uploadphoto(imageuri) { var options = new fileuploadoptions(); options.filekey="file"; options.filename=imageuri.substr(imageuri.lastindexof('/')+1); options.mimetype="image/jpeg"; var params = new object(); params.value1 = "test"; params.value2 = "param"; options.params = params; options.chunkedmode = false; var ft = new filetransfer(); ft.upload(imageuri, "http://clubbedin.clanteam.com/upload.php", win, fail, options); } function win(r) { console.log("code = " + r.responsecode); console.log("response = " + r.response); console.log("sent = " + r.bytessent); alert(r.response); } function fail(error) { alert("an error has occurred: code = " = error.code); }
here structure server
the path wrong, in case. /products/ might @ root when log in, web user might have different root. it's worth checking, @ least - if upload php file containing echo(getcwd()); should show php thinks path is. - @andrewsi
Comments
Post a Comment