Skip to content
Advertisement

move_uploaded_file not working on Apache server in Linux Mint

So I am trying to do a basic upload via an HTML form and a simple php script, but the move_uploaded_file function always returns false. I have run “chmod 777” on the directory (I will deal with safety more when I actually get this to work) and the “upload” directory is in the htdocs folder (actually /var/www in Ubuntu Server and Linux Mint).

Here is the form:

JavaScript

…and upload_file.php…

JavaScript

When I try to upload a small JPEG, I get “Failed to move file”. Any thoughts?

Advertisement

Answer

Your script needs to be able to write to the destination directory, which in this case would be /var/www/upload/ (is that the directory where you changed the permissions?). Also you are using the client’s local name which could be a possible problem and security issue (not necessarily the reason here though).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement