Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts

    HELP!!! Problem defining file loaction

    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:

    PHP Code:
    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:

    PHP 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?

  • #2
    New Coder
    Join Date
    Aug 2011
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Resolved by trimming the white space from the '$folder_id' variable:

    PHP Code:
    $folder_idtrim($folder_id); 

  • #3
    New Coder
    Join Date
    Apr 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.:
    PHP Code:
    $path "uploads/";
    $path1=$folder_id."/"
    Then move your file by:
    PHP Code:
    move_uploaded_file($file_tmp$path.$path1.$file_name

  • #4
    New Coder
    Join Date
    Aug 2011
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by php_rockzz View Post
    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.:
    PHP Code:
    $path "uploads/";
    $path1=$folder_id."/"
    Then move your file by:
    PHP Code:
    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.

  • #5
    New Coder
    Join Date
    Apr 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Mention not buddy.. It would b my pleasure if i can help u out in any way I can..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •