Noskiw Posted December 14, 2008 Share Posted December 14, 2008 as the title says, how would i do it? it is mainly going to be for SWF's, rar and mp4 hosting. i have looked up some tutorials on the Web but none useful. Link to comment https://forums.phpfreaks.com/topic/136964-how-would-i-go-about-making-a-simple-file-upload-system/ Share on other sites More sharing options...
timmah1 Posted December 14, 2008 Share Posted December 14, 2008 http://www.google.com/search?q=php+simple+upload&sourceid=navclient-ff&ie=UTF-8&rlz=1B3GGGL_enUS265US265 Link to comment https://forums.phpfreaks.com/topic/136964-how-would-i-go-about-making-a-simple-file-upload-system/#findComment-715347 Share on other sites More sharing options...
Mad Mick Posted December 14, 2008 Share Posted December 14, 2008 Here's the barebones for jpeg and pdf - modify to suit your filenames: <?php //file upload if (array_key_exists('submit',$HTTP_POST_VARS)){ if ($HTTP_POST_VARS['submit']) { print_r($HTTP_POST_FILES); if (!is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) { echo "You did not upload a file!"; unlink($HTTP_POST_FILES['file']['tmp_name']); // assign error message, remove uploaded file, redisplay form. } else { //a file was uploaded $maxfilesize=2500000; if ($HTTP_POST_FILES['file']['size'] > $maxfilesize) { echo "file is too large"; unlink($HTTP_POST_FILES['file']['tmp_name']); // assign error message, remove uploaded file, redisplay form. } else { if ($HTTP_POST_FILES['file']['type'] != "application/pdf" AND $HTTP_POST_FILES['file']['type'] != "image/pjpeg") { echo "This file type is not allowed"; unlink($HTTP_POST_FILES['file']['tmp_name']); // assign error message, remove uploaded file, redisplay form. } else { //File has passed all validation, copy it to the final destination and remove the temporary file: copy($HTTP_POST_FILES['file']['tmp_name'],"****YOUR UPLOAD LOCATION****".$HTTP_POST_FILES['file']['name']); unlink($HTTP_POST_FILES['file']['tmp_name']); echo "File has been successfully uploaded!"; exit; } } } } } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data"> <p><label for="photo">Choose a file to upload:</label> <input type="file" size="30" name="photo" /></p> <p><label></label> <input type="submit" name="submit" value="Upload" /></p> </form> Link to comment https://forums.phpfreaks.com/topic/136964-how-would-i-go-about-making-a-simple-file-upload-system/#findComment-715386 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.