Advertise here

Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Uploading an image via HTTP POST request

cjpearlcjpearl Posts: 111
edited April 2010 in iOS SDK Development
I have found several threads on this topic, but haven't been able to find where I'm going wrong in my code.

I'm trying to implement posting images to a website using this method, in post #11: . I have little to no experience with PHP, and am thinking that my error is probably on that side of things. I've tried using the Obj-C code as posted (changing the URL and filename as necessary), or commenting out the lines as mentioned in post #16, with no success.

I have the following file in my root directory for PHP scripts, saved as upload.php:
$uploaddir = '/myappname/uploads/';
$file = basename($_FILES['userfile']['name']);
$uploadfile = $uploaddir . $file;

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
        echo "{$file}";


...with no success upon sending POST requests with my app. I have tried commenting out lines in the app as suggested by post #16, and the response that gets logged to the console is either blank, or an error message that seems to mean that the file couldn't be copied from the temporary directory to /myappname/uploads (I'm away from my Mac at the moment and don't have the exact message :( ). Nothing gets uploaded to the server.

I am attempting to upload to a webhost for which I pay a monthly fee. I've tried changing the upload directory's file permissions to RWX (making it as open as possible).

Can anyone see where I may be going wrong?

Post edited by cjpearl on


Sign In or Register to comment.