Jump to content

Recommended Posts

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>';

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.