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 7543949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:33:38+00:00 2026-05-30T08:33:38+00:00

I am trying to save an uploaded image from an iPhone to a server

  • 0

I am trying to save an uploaded image from an iPhone to a server using PHP. I am using ASIHTTPRequest to handle the data request. This is my iPhone code:

[request setPostValue:someString forKey:@"string1"];
[request setPostValue:anotherString forKey:@"string2"];
[request addData:[NSData dataWithData:UIImageJPEGRepresentation(anImage, 0.9)]
         withFileName:@"img.jpg" andContentType:@"image/jpeg" forKey:@"img"];

[request startSynchronous];

On the server side, I am using this PHP code currently to try saving the image to a folder on my server:

print_r($_FILES);

$folder = 'upload/';
$image_path = basename($_FILES['img']['name']);
echo $folder . $image_path . "\n";
if (move_uploaded_file($_FILES['img']['tmp_name'], $folder . $image_path)) {
    echo 'ok!';
} 
else {
    echo 'fail !';
}

The strings are uploaded just fine and when I print_r() i see the contents of the image array as I expect, but for some reason when trying to save the image, i am getting “fail !” printed to the console. What is wrong here?

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-30T08:33:39+00:00Added an answer on May 30, 2026 at 8:33 am

    Try the following step before you move your image

    if(!is_dir($folder))
    {
       echo "Folder does not exist" ;
    
       if(!mkdir($folder))
       {
          echo "Attempt to create folder failed" ;
       }
    }
    else if(!is_writable($folder))
    {
       echo "Folder nto writeable" ;
    
       if(!chmod($folder, 0755))
       {
            echo "Attempt to make writeable failed" ;
       }
    }
     else {
    
       if (move_uploaded_file($_FILES['img']['tmp_name'], $folder . $image_path)) {
          echo 'ok!';
       }
       else {
        echo 'fail !';
       }    
    }
    

    What do you get ???

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to save a file (pdf or image) uploaded from a form into
I'm trying to save an excel spreadhseet from SQL Server Integration Services 2005. Unfortunatly
I am trying to save images using the following code: - (void)writeData{ if(cacheFileName==nil) return;
When trying to save an uploaded file, I get this error and are having
I am trying to load multiple files using HTML5. This is my code I
I am trying to save data to a database on a button push, but
I'm trying to save some XML-Data in my UserSettings (Properties.Settings.Default.UserSettings) in a .NET Winforms
I'm trying to save a PDF file to SQL Server and I already have
Hello I am trying to save a bitmap image in a basic image editor
Trying to get the width and height of the uploaded image while still in

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.