I want to check the folder. If I found "test.jpeg" in "path", if it is true, I do nothing, but if it is false, I need to upload this image like this
UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[dico objectForKey:@"photo"]]]]; nomPhoto = [[cell.pseudo text]stringByReplacingOccurrencesOfString:@"\n" withString:@""];; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString *document = [paths objectAtIndex:0]; filename = [NSString stringWithFormat:@"%@/%@.jpeg",document,nomPhoto]; NSData *data2 = [NSData dataWithData:UIImageJPEGRepresentation(image, 0.1f)];
EDIT: I'm trying this, but not working. the way is good
NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString* pict = [documentsPath stringByAppendingPathComponent :@"portos"]; BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:pict]; if (fileExists) { NSLog(@"file ok"); }else { NSLog(@"file ko"); }
THX
source share