Forum Moderators: coopster
I have a very weird problem with uploading files using a php script.
It returns error #7:
UPLOAD_ERR_CANT_WRITE Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0.
I have checked everything: target directory permissions, availability of temp directory, maximum allowed file size and post size limit. Everything is fine, what's more when I use a web proxy I can successfully upload the same files through it onto the server. I asked my colleague who is far away in another network to check it and he also can't upload files while the hosting support rep can do it successfully.
Please advise how to resolve it or at least where to start from...
Thanks
I asked my colleague who is far away in another network to check it and he also can't upload files while the hosting support rep can do it successfully.
Something is definately astray here. So this rep is using YOUR script? This is not a case of "it works in the sample script provided, not in your version?"
An anonymous user is an anonymous user. The only difference is the browser, IP, and network.
Start with the original error:
Failed to write file to disk.
There are a number of reasons you "can't write to disk." Some obvious ones:
- You're writing to a directory that doesn't exist
- you're writing to a directory outside root, and don't have permissions to do so (an apache user can't do this, but a root user can.)
- you're writing to a directory for which permissions OR ownership are not set.
How can these occur?
Script is in /home/domainname.com
write to => home/domainname.com/uploads
See the error? If you start from domainname.com, this is asking to write to /home/domainname.com/home/domainname.com/uploads, which doesn't exist. A single typo like this can cause all the grief you need to start sprouting gray hair.
The way I like to do this:
Create a variable named "$debug" at the top.
Throughout your script drop it in key points:
$debug .= " entering script ";
......
$debug .= " uploading file ";
......
$debug .= " file uploaded, moving to $move_to ";
......
$debug .= " file moved, returning response ";
......
$debug .= " done ";
echo "<!-- $debug -->";
This allows it to run normally and points to exactly where it's going wrong, and why.
Returning to the original quote - why can your rep do it - try a different browser. It could be something on your end, a virus, who knows?
One last thing, you ARE using enctype multipart/form-data on the form, right? (Shouldn't cause this, but just the same . . . )