Reputation: 2514
i am new in web services in php i don't now what is the behavior of ios to upload image so i write down my PHP code can anybody help me what is wrong in php code or there something wrong in ios code
$picName = $_FILES['name']['pic_data'];
move_uploaded_file($_FILES["file"]["tmp_name"], 'images/'.$picName);
Upvotes: 0
Views: 1720
Reputation: 3592
You could refer the below link to know how to upload image and use mysql to manage it.
http://www.raywenderlich.com/13511/how-to-create-an-app-like-instagram-with-a-web-service-backend-part-12 http://www.raywenderlich.com/13541/how-to-create-an-app-like-instagram-with-a-web-service-backend-part-22
Upvotes: 0
Reputation: 2514
Thanx Alot i know what i do wrong so thanx to ernaidu and asad Mahmood
this Wrong::
$picName = $_FILES['name']['pic_data'];
move_uploaded_file($_FILES["file"]["tmp_name"], 'images/'.$picName);
This is right::
$picName = $_FILES['pic_data']['name'];
move_uploaded_file($_FILES["pic_data"]["tmp_name"], '../images/'.$picName);
Upvotes: 0
Reputation: 68
I think you must be sending like this:
xhrRegister.send({ file : selectedPhoto });
and you can get it in PHP like this:
if ($_FILES["file"]["error"] > 0) {
// ERROR
} else {
$filename = uniqid() . $_FILES["file"]["name"];
$filetype = $_FILES["file"]["type"];
move_uploaded_file($_FILES["file"]["tmp_name"], 'images/' . $filename);
}
Upvotes: 4