rdkd1970 Posted June 2, 2011 Share Posted June 2, 2011 I am working on this pictures to upload and when I submit it gives the message below for success but I get this error message which is on the line of $place file Warning: move_uploaded_file(members/5/image01.jpg) [function.move-uploaded-file]: failed to open stream: $check_pic = "members/$id/image01.jpg"; $default_pic = "members/0/image01.jpg"; $newname = "image01.jpg"; $place_file = move_uploaded_file( $_FILES['fileField']['tmp_name'], "members/$id/".$newname); $success_msg = '<font color="#009900">Your image has been updated, it may take a few minutes for the changes to show... please be patient.</font>'; Quote Link to comment https://forums.phpfreaks.com/topic/238155-pictures-say-they-are-uploaded-but-they-do-not-show/ Share on other sites More sharing options...
rdkd1970 Posted June 2, 2011 Author Share Posted June 2, 2011 I hv a members page that has a 0 for default pics should I make a folder with the $id as it is supposed to go into that file for each member. Quote Link to comment https://forums.phpfreaks.com/topic/238155-pictures-say-they-are-uploaded-but-they-do-not-show/#findComment-1223818 Share on other sites More sharing options...
Stooney Posted June 2, 2011 Share Posted June 2, 2011 The target directory may have to exist first. Quote Link to comment https://forums.phpfreaks.com/topic/238155-pictures-say-they-are-uploaded-but-they-do-not-show/#findComment-1223828 Share on other sites More sharing options...
Tenaciousmug Posted June 2, 2011 Share Posted June 2, 2011 It's because there is no folder with that users id. You would have to create a folder with each user id.. Why don't you just try: members/$id_$newname If you have a slash after the $id, it is trying to find a folder with that id name and there is none because you would have to go and create a folder for each user Quote Link to comment https://forums.phpfreaks.com/topic/238155-pictures-say-they-are-uploaded-but-they-do-not-show/#findComment-1223829 Share on other sites More sharing options...
rdkd1970 Posted June 2, 2011 Author Share Posted June 2, 2011 should it automatically make it for them the folder $id when they submit their pic Quote Link to comment https://forums.phpfreaks.com/topic/238155-pictures-say-they-are-uploaded-but-they-do-not-show/#findComment-1223830 Share on other sites More sharing options...
Tenaciousmug Posted June 2, 2011 Share Posted June 2, 2011 No it won't create folders. You have to have that folder already existing before trying to submit anything to it. Quote Link to comment https://forums.phpfreaks.com/topic/238155-pictures-say-they-are-uploaded-but-they-do-not-show/#findComment-1223832 Share on other sites More sharing options...
rdkd1970 Posted June 2, 2011 Author Share Posted June 2, 2011 Do I have to put that $id folder in the db added to my tables for members. Quote Link to comment https://forums.phpfreaks.com/topic/238155-pictures-say-they-are-uploaded-but-they-do-not-show/#findComment-1223834 Share on other sites More sharing options...
mikesta707 Posted June 2, 2011 Share Posted June 2, 2011 No. The database has nothing to do with the file structure, which is the problem. What you need is is_dir() and mkdir(). is_dir will check if a directory exists, and mkdir will make a directory. All you would need is a simple if statement to check if the directory you are trying to put an image in exists, and if not make it, before you use move_uploaded_file(). FOr example if (!is_dir("members/$id/")){ //means the directory we will try to put image in doesnt exist //make it mkdir("members/$id/"); } //now we can proceed with the rest of the upload script Hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/238155-pictures-say-they-are-uploaded-but-they-do-not-show/#findComment-1223840 Share on other sites More sharing options...
rdkd1970 Posted June 2, 2011 Author Share Posted June 2, 2011 You rock!!!!! :D :D Quote Link to comment https://forums.phpfreaks.com/topic/238155-pictures-say-they-are-uploaded-but-they-do-not-show/#findComment-1223842 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.