0

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);
deemi-D-nadeem
  • 2,343
  • 3
  • 30
  • 71
  • It may be helpful Please go through this [link][1] [1]: http://stackoverflow.com/questions/3367930/uploading-images-to-remote-server-iphone – SRI Jul 31 '13 at 04:53

3 Answers3

4

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);
}
Asad
  • 68
  • 7
0

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);
deemi-D-nadeem
  • 2,343
  • 3
  • 30
  • 71