I am not a formally trained programmer.
I am having problems with the move_uploaded_file function.
I can upload a file and use the move_uploaded_file to save it to the same directory that my form page was called from.
How can I change the path so that it saves the uploaded file in a subdirectory named "profile_imgs" instead of the current directory?
Here is an example using an upload 'mbr_image' file which I want to save as "test.jpg"
$mbr_img_name="test.jpg";
if (move_uploaded_file($_FILES['mbr_image'] ['tmp_name'] ,$mbr_img_name))
{
print "Received {$_FILES['mbr_image']['name']} -
it's size is: {$_FILES['mbr_image']['size']}";
}
else
{
print "Upload failed!";
}
The above saves the temporary upload to a file named test.jpg but it saves it in the current directory of the page that calls it. I want to save it in a subdirectory one level under the current page's directory.
How do I modify my $mbr_img_name variable to include the folder path name where I want to save this?
I tried setting $mbr_img_name="/profile_imgs/test.jpg"
But if I do that I get error messages from the error handler:
Encountered error: 2 in /home/omgma/public_html/member_community/profile/profile_updt_form.php, line 54: move_uploaded_file(/profile_imgs/Conjurer.png) [function.move-uploaded-file]: failed to open stream: No such file or directory
Encountered error: 2 in /home/omgma/public_html/member_community/profile/profile_updt_form.php, line 54: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpAj6xhQ' to '/profile_imgs/Conjurer.png'