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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:58:13+00:00 2026-06-18T15:58:13+00:00

Is it possible to convert NSData/UIImage Data Representation as JPEG to a String, to

  • 0

Is it possible to convert NSData/UIImage Data Representation as JPEG to a String, to be sent over HTTP to a PHP File to save this string in a database, and then retrive it later on in the application and convert it back into an NSData/UIImage Object?

I have tried Base64 Encoding Libraries but base64 doesn’t seem valid as the image doesn’t display correctly on a HTML Page.

Any suggestions?

Edit.

I was using the following library:

http://www.imthi.com/blog/programming/iphone-sdk-base64-encode-decode.php

And converting in the following way:

 NSData *imageData = UIImageJPEGRepresentation(MyImage.image, 90);
[Base64 initialize];
NSData *encoded = [Base64 encode:imageData];
NSLog(@"%@",encoded);

This does chug out alot of BASE64 but when I save it to a file and try to view it, I just get the eror loading image [?] in Chrome.

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-06-18T15:58:15+00:00Added an answer on June 18, 2026 at 3:58 pm

    The point of encoding an NSData object to base 64 is so you can represent the data as a string that can be stored or transferred more easily. You then need to decode the base 64 encoded string back into NSData. This data can then be used to create a new UIImage. Your server needs to do this decoding to get back the original data.

    Your code has a mistake. This line:

    NSData *encoded = [Base64 encode:imageData];
    

    should be:

    NSString *encoded = [Base64 encode:imageData];
    

    Notice that you get back a string, not data.

    You commented that you wrote the encoded string to a file then couldn’t view the image. Of course not. If you want to write the image data to a file so the file is actually viewable as the image, then don’t encode the data first. Write the raw image data to a file.

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

Sidebar

Related Questions

Possible Duplicate: NSData to UIImage How do I convert a NSData value to UIImage?
Is it possible to convert this java code snippet to php? public void testBalanceReturnsToZeroOnVending()
Possible Duplicate: Convert NSDate to NSString convert string to nsdate Currently I have this
Possible Duplicate: Convert this string to datetime I have to convert my string value
Possible Duplicate: convert string to nsdate I have this string Fri, 07 Dec 2012
Is it possible convert an NSData *dataImage witch was a format jpeg or png
Possible Duplicate: Convert a number to the shortest possible character string while retaining uniqueness
Is it possible to convert a String to a type, which is definied by
Is it possible to convert facebook data (ex. user_pic) into a DisplayObject so I
Possible Duplicate: Convert XML/HTML Entities into Unicode String in Python I am reading an

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.