- How to Code the ActionScript
- How to Write the PHP
- Conclusion
How to Write the PHP
The PHP for handling the file upload is a very small and simple script. (Note that no security is added to the script; I’m leaving that part to you.) The method that we use to move the file to a specific location on the server is move_uploaded_file. This method takes two parameters: a string filename representing the selected file, and a string destination representing the server location where we want the file to be uploaded.
move_uploaded_file($_FILES[’Filedata’][’tmp_name’], "./files/".$_FILES[’Filedata’][’name’]);
The second line of code handles setting the correct permissions for UNIX and Linux servers. In this example, we set full permission for the uploaded file.
chmod("./files/".$_FILES[’Filedata’][’name’], 0777);