...

View Full Version : HELP!!! Problem defining file loaction



RossBryan
04-09-2012, 07:55 AM
Can anybody point me in the right direction of what exactly it is im doing wrong please. Im trying to upload a file to a specific location (folder), it works fine when i simply specify the uploads folder using the following:


if (move_uploaded_file($file_tmp,'uploads/'.$file_name))

However when attempting to point to a folder (that exists) inside the uploads folder 'uploads/11' using a variable in the following code:


if (move_uploaded_file($file_tmp, 'uploads/'.$folder_id.'/'.$file_name))

I get the error messages:


Warning: move_uploaded_file(uploads/ 11 /CV.doc) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\xampp\htdocs\boxedIN\upload.php on line 62


Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\php59.tmp' to 'uploads/ 11 /CV.doc' in C:\xampp\htdocs\boxedIN\upload.php on line 62

Any suggestions?

RossBryan
04-09-2012, 09:55 AM
Resolved by trimming the white space from the '$folder_id' variable:


$folder_id= trim($folder_id);

php_rockzz
04-09-2012, 09:57 AM
The code should work.. Cant figure out the exact problem from just a single line.
I tried to upload a file into a subfolder using the following code. U can see if it works for u.. Even though i dont think there's much difference between ur code and mine.:


$path = "uploads/";
$path1=$folder_id."/";


Then move your file by:


move_uploaded_file($file_tmp, $path.$path1.$file_name)

RossBryan
04-09-2012, 10:43 AM
The code should work.. Cant figure out the exact problem from just a single line.
I tried to upload a file into a subfolder using the following code. U can see if it works for u.. Even though i dont think there's much difference between ur code and mine.:


$path = "uploads/";
$path1=$folder_id."/";


Then move your file by:


move_uploaded_file($file_tmp, $path.$path1.$file_name)


Thanks, I do have it working now using the solution mentioned previously. I did however give your way a try out of curiosity , but it doesn't seem to work either just as my initial code didn't; same error comes up when run. For some reason there is white space in the '$folder_id' variable which appears to be causing the problem of the folder location not being found.

All the same thanks for taking the time and effort to have a look at my post and help out.

php_rockzz
04-09-2012, 11:32 AM
Mention not buddy.. It would b my pleasure if i can help u out in any way I can.. ;):thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum