views:

50

answers:

3

Same script is working fine in localhost but it is not working in server. It is throwing some error-

Warning: copy(album/6349416.jpg) [function.copy]: failed to open stream: Permission denied in D:\Hosting\6448289\html\upload.php on line 112

corresponding 112 line is-

$image_name=$unq.'.'.$extension;
//the new name will be containing the full path where will be stored (album folder)
$newname="album/".$image_name;
$copied = copy($_FILES['image']['tmp_name'], $newname);  //112th line
+1  A: 

$newname should be full path to a new file. But in your script it is a relative path that seem to point somewhere inside /tmp

FractalizeR
I think that $newname will will point to to current folder of the executing script ..
Bang Dao
means it should be like- `http://domain.com/album/`
amanda
No, it should be like /home/mysite/www/upload/album. You can use dirname(__FILE__) to get the directory name of the current PHP script.
FractalizeR
A: 

Check the permissions of the album folder. It should end with 6 or 7 (read+write have to be enabled for everybody-permissions)

VeeWee
i have checked all permissions.
amanda
Does that file exist already? It's not enough to just have write permissions on the directory. If you're overwriting an existing file, you have to have write permission for the file as well.
Marc B
A: 

This might be a stupid question, but are you using a windows server?

You've used a forward-slash (unix-style) in "album/".$image_name but the error location is shown with backslashes (windows style) "D:\Hosting\6448289\html\upload.php". Does it still fail with a backslash, i.e. "album\".$image_name?

edit: I forgot add - you might need a ./ or .\ at the front of the location to declare it relative to the php script's current location

PhilI
PHP will convert / separators to \ on Windows systems automatically. `"album\".$image_name` would cause a syntax error anyways, as the \ will escape the double-quote and lead to an unterminated string. `"album\\".$image_name` would work, though.
Marc B