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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:17:42+00:00 2026-06-15T13:17:42+00:00

Here is my code to upload image to php server but image is uploaded

  • 0

Here is my code to upload image to php server but image is uploaded as corrupted image at server.Below is my code please tell me the issue..I have tried with cocoa rest client, image is uploading properly from it.

    NSString *filename = @"connect-blue.png";
    UIImage *image = [UIImage imageNamed:filename];
    NSMutableURLRequest * request= [[[NSMutableURLRequest alloc] init] autorelease];
    [request setURL:[NSURL URLWithString:urlString]];
    [request setHTTPMethod:@"POST"];
    NSString *boundary = @"---------------------------14737809831466499882746641449";
    NSString *contentType = [NSString stringWithFormat:@"multipart/form-data;    boundary=%@",boundary];
    [request addValue:contentType forHTTPHeaderField: @"Content-Type"];
    NSMutableData *postbody = [NSMutableData data];
    [postbody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [postbody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"profile_image\"; filename=\"%@\"\r\n",filename] dataUsingEncoding:NSUTF8StringEncoding]];
   [postbody appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];

    [postbody appendData:[postString dataUsingEncoding:NSUTF8StringEncoding]];
    NSData *imagedata = UIImageJPEGRepresentation(image,1.0f);

    [postbody appendData:[NSData dataWithData:imagedata]];
    [postbody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary]  dataUsingEncoding:NSUTF8StringEncoding]];

Php code is here

if(!empty($_FILES)){
//
  $imgname=$_FILES['image']['name'];
         $a=pathinfo($imgname);

  if(!empty($a['extension'])){  
   $img_name=$a['filename'];
   $img_ext=$a['extension'];
 }

  else

  {

    $img_name='';

   $img_ext='';

   }

   $img_pre=mktime();

   $image1=$img_pre."_".$imgname;
  move_uploaded_file($_FILES['image']['tmp_name'],  "uploads/images/" .  $image1);
  • 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-06-15T13:17:43+00:00Added an answer on June 15, 2026 at 1:17 pm

    I found the solution Image Uploading

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

Sidebar

Related Questions

I have this line of CSS code here... background-image:url(upload/<?php echo $array['image']; ?>); but the
I have an issue with multiple images upload to php server. The code given
I have piece of code (imageupload.php) below where the php is suppose to upload
Here my code, I need to insert into mysql database I have mysql,php,android 1)
I'm trying to upload an image from android to a PHP server by using
I need to upload image from iphone application to PHP server for some processing
I write php code to allow user to submit image and upload it to
I'm look for a solution to upload an image file to PHP server I
I searched online for a code that does PHP image upload using ajax. I
Iam looking for jquery php image upload exactly given in http://valums.com/ajax-upload/ . i tried

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.