views:

418

answers:

2

I am using the following code (with ASIHTTPRequest) to attempt to upload php files from my iPhone to my LAN MAMP server running on my Macbook Pro. My objective-c and my php seem to be in line, but the files are not uploading.

OBJECTIVE-C CODE

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [paths objectAtIndex:0];
[path stringByAppendingPathComponent:[pieces objectAtIndex:indexPath.row]];

NSURL *url = [NSURL URLWithString:@"http://192.168.1.102:8888/upload.php"];


ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
[request setFile:path forKey:@"file"];

PHP CODE

 <?php
$target = "uploads/";
$target = $target . basename( $_FILES['file']['name']) ;
$ok=1;
(move_uploaded_file($_FILES['file']['tmp_name'], $target));
?>

What is going wrong here?

Thanks,

James

A: 

Code looks fine. Are you sure your server's PHP configuration is accepting uploads, and that the CSVs are within the size limitation?

Kirk van Gorkom
A: 

Does the Apache httpd process have the privileges to write in the uploads/ directory? Try setting it to /tmp/ and see if that works?

I created a backup solution for AppSales-Mobile using a small php script. Wrote about it here. The php script I created looks like this. The actual post code can be viewed here in the method - (void) startUpload.

epatel