php - What script to write on receiving file? -
i have created script takes photo , transfers remote server follow tutorial here. seems working, unsure write on recieving end of script, ie: need put on php file on server.
ultimately, write image directory on server , save path database.
would know function(s) should for, this? cannot find in cordova manuals , pretty lost do.
should using phps get
or request
functions?
(i creating app ios in xcode)
my code is:
smallimage.src = "data:image/jpeg;base64," + imageuri; var fail, ft, options, params, win; // callback when photo has been uploaded: var success = function(response) { alert("photo saved"); }; // callback if photo fails upload successfully. var fail = function(error) { alert("an error has occurred: code = " + error.code); alert(filetransfererror.connection_err); }; options = new fileuploadoptions(); // parameter name of file: options.filekey = "my_image"; // name of file: options.filename = imageuri.substr(imageuri.lastindexof('/') + 1); // mime type: options.mimetype = "text/plain"; params = { val1: "some value", val2: "some other value" }; options.params = params; ft = new filetransfer(); ft.upload(imageuri, 'http://mysite.com/appimages/recieve.php', success, fail, options);
(nb: recieve.php blank)
you can use following code save uploaded file
<?php $target_path = "tmp/"; if ($_files["my_image"]["error"] > 0){ echo "error: " . $_files["my_image"]["error"] . "<br>"; } else{ if (file_exists($target_path . $_files["my_image"]["name"])){ echo $_files["my_image"]["name"] . " exists. "; } else{ move_uploaded_file($_files["my_image"]["tmp_name"], $target_path . $_files["my_image"]["name"]); echo "stored in: " . $target_path . $_files["my_image"]["name"]; } } ?>
Comments
Post a Comment