Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-15-2009, 10:42 PM   #1 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 17
Default How to save image from UIWebview to App's document folder

Hi guys,

I need to save images from UIWebview to my app's document folder, the image format may be jpg, gif, png or others. I have two questions,
1: How to detect whether I select a image or don't, and which image is selected.
2:How to save image to the document folder.

anyone can guide me ?
Thank you !
wode211 is offline   Reply With Quote
Old 06-16-2009, 10:03 AM   #2 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 17
Default

anyone knows ?
wode211 is offline   Reply With Quote
Old 06-18-2009, 05:37 AM   #3 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 17
Default

any idea?
wode211 is offline   Reply With Quote
Old 02-04-2010, 05:10 AM   #4 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 49
Default

I have the same problem. Any ideas?
schimanke is offline   Reply With Quote
Old 08-06-2010, 05:10 AM   #5 (permalink)
Registered Member
 
Join Date: Jan 2010
Location: New Delhi
Posts: 11
Default Any Idea

I am still facing same problem. Can anyone please give the idea

Thanks in advance
-Muzammil
muz.aazmi@gmail.com
muzammil is offline   Reply With Quote
Old 08-06-2010, 05:25 AM   #6 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Amsterdam, The Netherlands
Posts: 782
Default

Are you using the UIWebView to kust one image?
Which means that you know the URL of that image.

Them you should just download the image via NSURLRequest and save the data, after which you can just display the image in a normal UIImageView.
There a lot tutorials on how to do this, just search for async imageview.

If you want the user to be able to select an image displayed in the webview where there are multiple images. Then you should look at some kind of Javascript method and create a custom URL schema, which you can then pick-up from you code.
Then just the method above to download.
TUX2K is offline   Reply With Quote
Old 03-01-2011, 07:28 AM   #7 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 7
Thumbs up dowloading an image from web

Quote:
Originally Posted by wode211 View Post
anyone knows ?
1. make a text field to obtain url of image . You can get the url through this piece of code

- (void)webViewDidStartLoadUIWebView *)webView
{
url1 = [webView.request URL];
urlField.text = [url absoluteString];
}
2. make proper connection of delegate of UIWebView in file's owner.
3. make button to download the image!! and method in which u can write!!




url = [webView.request URL];
NSLog(@"url recieved: %@", url);
NSLog(@"Downloading...");
// Get an image from the URL below
UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:url]];
//UIImage *image = [[UIImage alloc] init];
NSLog(@"%f,%f",image.size.width,image.size.height) ;
// Let's save the file into Document folder.
// You can also change this to your desktop for testing. (e.g. /Users/kiichi/Desktop/)
NSString *deskTopDir = @"/Users/gauravmurghai/Desktop";
//NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory, NSUserDomainMask, YES) objectAtIndex:0];
// If you go to the folder below, you will find those pictures
NSLog(@"%@",deskTopDir);
NSLog(@"saving png");
NSString *pngFilePath = [NSString stringWithFormat:@"%@/jpg.png",deskTopDir];
NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(image)];
[data1 writeToFilengFilePath atomically:YES];
NSLog(@"saving jpeg");
NSString *jpegFilePath = [NSString stringWithFormat:@"%@/jpg.jpeg",deskTopDir];
NSData *data2 = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0f)];
[data2 writeToFile:jpegFilePath atomically:YES];
NSLog(@"saving image done");
[image release];
app2011 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 158,481
Threads: 89,092
Posts: 380,127
Top Poster: BrianSlick (7,091)
Welcome to our newest member, paverlight
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:37 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0