Advertise here




Advertise here

Howdy, Stranger!

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

Sign In with Google Sign In with OpenID

Uploading an image via HTTP POST request

cjpearlcjpearl Posts: 111Registered Users
edited April 2010 in iPhone 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: http://www.iphonedevsdk.com/forum/iphone-sdk-development/3074-posting-file-web-site.html . 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:
<?php
$uploaddir = '/myappname/uploads/';
$file = basename($_FILES['userfile']['name']);
$uploadfile = $uploaddir . $file;

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
        echo "http://www.mycompanywebsite.com/myappname/uploads/{$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?

Thanks!
Post edited by cjpearl on

Replies

Sign In or Register to comment.