php - Error to Upload Image on server from iphone -
i trying upload photo on server using php. want upload photo on server save name in mysql database request asiformdatarequest. want upload photo on local server directory folder.
if ([arrimages count] > 0) { nsstring *strurl = @"http://localhost/apneareamein/upload_file.php"; asiformdatarequest *request = [asiformdatarequest requestwithurl:[nsurl urlwithstring:strurl]]; [request setdelegate:self]; [request setpostvalue:@"this sample text..." forkey:@"company_logo"];//here write downwards text sent. (int = 0; < [arrimages count]; i++) { [request adddata:[arrimages objectatindex:i] withfilename:@"image.jpg" andcontenttype:@"image/jpeg" forkey:[nsstring stringwithformat:@"image%d", + 1]]; } [request startasynchronous]; } else { uialertview *alertview = [[uialertview alloc]initwithtitle:@"message" message:@"please select images..." delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alertview show]; }
my php code is <?php $con = mysql_connect('localhost','root'); mysql_select_db('apnemein_forms',$con); $uploaddir = 'http://localhost/apneareamein/uploads/'; //folder named upload, image saved (same dir file) $file = basename($_files['company_logo']['company_logo']); $uploadfile = $uploaddir . $file; if (move_uploaded_file($_files['company_logo']['tmp_name'], $uploadfile)) { echo "file not uploaded"; //i'm not sure this, works me } else { echo "<img src=\"uploads/photopicker.jpg\" />"; } ?>
change path of uploading folder from
$uploaddir = 'http://localhost/apneareamein/uploads/';
to $uploaddir = getcwd().'/uploads/';
this solve problem
php ios mysql iphone
No comments:
Post a Comment