...

View Full Version : Move_uploaded_file Error



username85
10-18-2012, 01:36 AM
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:


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

Fou-Lu
10-18-2012, 02:59 AM
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.

Inigoesdr
10-18-2012, 03:00 AM
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.

username85
10-18-2012, 03:14 AM
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?

Fou-Lu
10-18-2012, 05:57 AM
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:


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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum