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
    Feb 2012
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Move_uploaded_file Error

    Hey all,

    Can anybody let me know how to correct the 'move_uploaded_file:failed to open stream' error?

    After trying to upload an image, I get the following errors:

    Warning: move_uploaded_file(/var/websites/backpage_php/web/files/34/crv.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in D:\Hosting\9977835\html\edit.php on line 26

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\phpA725.tmp' to '/var/websites/backpage_php/web/files/34/crv.jpg' in D:\Hosting\9977835\html\edit.php on line 26

    the code for in the edit.php file is:

    PHP Code:
    11 if($_POST["task"]=="Save"){
        
    $rs $_POST;
        
    $msg "";

    15    $rs["type"] = $type;

        if(
    $msg==""){

    19        $rs["status"] = "Active";
            
    $rs["user_id"] = $user_id;
            
            
    ///upload        
    23        $target_path file_path.$rs["list_id"];

            
    $new_pic1 basename($_FILES['photo']['name']);
    26        if($new_pic1!="" && move_uploaded_file($_FILES['photo']['tmp_name'], $target_path ."/"$new_pic1)) {
                
    $rs["photo"] = $new_pic1;
            }

            
    //update photo
            
    update_list($rs);

            
    $msg lang("Saved");
            
            
    $activation_id $rs["activation_id"];
        }

    Thanks.

    -Rafal
    Last edited by username85; 10-18-2012 at 01:38 AM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I assume those numbers are just line numbers.
    Look at these paths: /var/websites/backpage_php/web/files/34/crv.jpg compared to: D:\Temp\php\phpA725.tmp.
    You are attempting to move a file to an invalid location in your filesystem. Your code is running on a windows system, but you are attempting to move it to a path that is a *nix fileystem. So the error is that the directory you want to move into simply doesn't exist. Look into the file_path constant you have here to change the value to a non-linux filepath.

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Given that your temporary path is on "D:\", I suspect this is a Windows server which would mean the destination path "/var/websites/backpage_php/web/files/" is incorrect.

  • #4
    New Coder
    Join Date
    Feb 2012
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    I assume those numbers are just line numbers.
    Look at these paths: /var/websites/backpage_php/web/files/34/crv.jpg compared to: D:\Temp\php\phpA725.tmp.
    You are attempting to move a file to an invalid location in your filesystem. Your code is running on a windows system, but you are attempting to move it to a path that is a *nix fileystem. So the error is that the directory you want to move into simply doesn't exist. Look into the file_path constant you have here to change the value to a non-linux filepath.
    Where/How do I find that value?

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by username85 View Post
    Where/How do I find that value?
    Haven't a clue. That's a user defined constant (although I won't recommend lower case for constants, this clearly is since it parses to a filepath), so you'll have to go through your code to find it.
    Either this or file_path does actually fail (enable your error reporting with:
    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL); 
    It'll tell you if you try using a string as an undefined constant), and $rs['list_id'] contains the full path. Either way you need to debug for this as we cannot do it with any type of user created variables that aren't shown here.


  •  

    Posting Permissions

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