Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3285768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:18:14+00:00 2026-05-17T20:18:14+00:00

I try to send a photo and GPS location to server via PHP here

  • 0

I try to send a photo and GPS location to server via PHP

here is the PHP part:Copy from here
Saving the Uploaded File

The examples above create a temporary copy of the uploaded files in the PHP temp folder on the server.

The temporary copied files disappears when the script ends. To store the uploaded file we need to copy it to a different location:

<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }
?>

The script above checks if the file already exists, if it does not, it copies the file to the specified folder.

Note: This example saves the file to a new folder called “upload”

now back to iOS part ,I only can send GPS location to server ,it’s easy because just a string.

and you can download sample code here

But an image is not,I do some search and found this discussion

I directly put the code in my send GPS&image button

the best thing is it can feedback I send the file success or failed

this is the most message I got after I send photo to server

1.Invalid file

2.Return Code:
Upload:
Type:
Size: 0 Kb
Temp file:
Stored in: upload/

I follow some guide to save image to NSData

NSData *photoData= UIImageJPEGRepresentation(self.theimageView.image, 1.0);

and I also check there is data inside or not

so simply add this code into Button action

if (photoData == nil) {
    NSLog(@"The photo is nothing !!!");
}
else {
    NSLog(@"Photo inside !!!!");

It works fine…….

But How To Upload An Image To Server ???

maybe I need to give a file name then upload it ???

but how to…

I never use camera function and upload data before

Hope someone can figure out this problem

Many Great Thanks !!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:18:14+00:00Added an answer on May 17, 2026 at 8:18 pm

    use HTTP multipart POST or ASIHTTPRequest


    @WebberLai
    
    Save the image to home directory:
     NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.jpg"];
        UIImage *img = pickerImage;
    
    
    // Write a UIImage to JPEG with minimum compression (best quality) 
        [UIImageJPEGRepresentation(img, 0.5) writeToFile:jpgPath atomically:YES];
    
        NSString *photoPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.jpg"];
    
        request = [ASIFormDataRequest requestWithURL:webServiceUrl];
        [request setPostValue:requestString forKey:@"data"];
        [request setFile:photoPath forKey:@"apiupload"];
        [request startSynchronous];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to upload a file(photo) from Flex to Rails and then send a
I try to send a message from to global page to my injected.js on
I try to send POST data to a server using urlfetch in AppEngine. Some
My ActionMailer scripts look perfectly fine. However when I try to send from the
Im trying to read in image file from a server , with the code
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
I try to fetch a Wikipedia article with Python's urllib: f = urllib.urlopen(http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes) s
We try to convert from string to Byte[] using the following Java code: String
I try to write KSH script for processing a file consisting of name-value pairs,
I try to instantiate an instance of SPSite on the farm server in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.