|
|
|
Home Credits Affliates Link Exchange HTMLshaman PHPshaman LINUXshaman Helpful Links Web Design Images Backgrounds Icon Sets GIF Images |
Simple Scripts : File Upload PHP can also be used for uploading of files directly to your server online and reduces the need for you to log into FTP or do it on the SHELL. However, do bear in mind that it uses the Apache Daemon to do it and what ever permission rights the Apache Daemon has, the script's loaded file will have too and can be dangerous if not carefully monitored. Before we present to you the script the following is the danger of having it running on your site unmonitored and the risks involved. If the HTTPD ( Apache Daemon ) is set to run as a root user and have root rights to your system, a user can upload a SHELL, PERL or even another PHP script. But remember that this file is loaded by the root user and will have root rights to the system because for the simple fact that the HTTPD is the same level as the root user, if this script is excuted and runs SHELL commands to delete all files in the system, example issue the "exec ("rm -R /*");" line in the script, the system will think that its the root user doing it and will wipe out everything that is in your system and leaving no trace of it. Now that you know the risk involved, please proceed with caution and below is the sample upload file script that is coded in both PHP and HTML. <html> <head> <title>Sample Upload Script</title> </head> <?php // Below must be the absolute path to the directory $file_dir = "/location/to/the/directory/to/load/files"; // Below is the URL fo the directory $file_url = "http://www.domain.com/upload/directory"; foreach( $HTTP_POST_FILES as $file_name => $file_array ) { print "path: ".$file_array['tmp_name']."<br>\n"; print "name: ".$file_array['name']."<br>\n"; print "type: ".$file_array['type']."<br>\n"; print "size: ".$file_array['size']."<br>\n"; if ( is_uploaded_file( $file_array['tmp_name'] ) && $file_array['type'] == "image/gif" ) { move_uploaded_file( $file_array['tmp_name'], "$file_dir/$file_name") or die ("File cannot be copied"); print "<img src=\"$file_url/$file_name\"><p>\n\n"; } } ?> <body> <form enctype="multipart/form-data" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="25600"> <input type="file" name="fupload"><br> <input type="submit" value="Upload File"> </form> </body> </html>
|
| Our Recommended Links |
|
|
Contact us at webmaster@galacnet.com for advertising opportunities on GalacNet. |