You can use PHP to allow your users to upload a file to the server.To allow users to upload a file to the server, you first need to provide a form for them to specify which file they want to upload.

Rengodating com php video

(Ignore any carriage returns in this example - each table row should be on one line). $_FILES["file To Upload"]["error"]; } else { move_uploaded_file($_FILES["file To Upload"]["tmp_name"], "C:/upload/" .

$_FILES["file To Upload"]["name"]); } Letting your users upload files to your server can be very risky.

If you're not careful, you could get users uploading all sorts of files - perhaps including harmful executables etc.

It doesn't move the file to another location - we'll get to that next.

For now, you can use this code in conjunction with the above input form to demonstrate what happens when you upload a file to the server.

Notice the PHP $_FILES array which contains info about the file.

Note that we also divide the file size by 1024 in order to convert it into kb. If the value is greater than zero, you know an error has occurred and you can present a user friendly message to the user. 0) { echo "Apologies, an error has occurred."; echo "Error Code: " .

Before a user can upload a file, you need to provide them with an interface that allows them to select a file and initiate the upload. There are a couple of important things to note about this code: Once the user uploads a file, the file is uploaded into a temporary directory on the server. Therefore, your action page needs to move the file to another location where it can stay as long as you want it to.

Whenever a file is uploaded, you can find out certain information about the file including its name, type, size, as well as the name of the temporary file on the server.