Code:
| Code: |
| <?php
if ( !isset($_FILES['data']['name']) || $_FILES['data']['name'] == "") { die('No input file specified. Please go back and select a file to upload.'); } $max_filesize = 209715200; //max file size 200mb $upload_path = '/uploads/'; //upload path $filetype = array('text/plain','image/jpg,'image/png','image/gif','image/bmp','application/octet-stream','application/x-sdlc','image/jpeg','audio/mpeg','image/pjpeg','audio/mpeg','application/zip','audio/x-wav','video/mpeg'); if ($_FILES['data']['size'] > $max_filesize) { die('Your filesize is too large. Please make your file size smaller than ' . $max_filesize . ' bytes.'); } if (!in_array($_FILES['data']['type'], $filetype)) { $i = 0; $count = count($filetype); $filetype_msg = ''; while ($i <= $count) { $filetype_msg .= " ".$filetype[$i].","; $i++; } die('Sorry, your file was not of the ' . $filetype_msg . ' mimetype (yours was ' . $_FILES['data']['type'] . ').'); } $copy_to = $_SERVER['DOCUMENT_ROOT'] . $upload_path . $_FILES['data']['name']; $upload = move_uploaded_file($_FILES['data']['tmp_name'], $copy_to); if (!$upload) { die('Sorry, your file could not be uploaded.'); } echo 'Your file has been uploaded. You can access it by going to http://www.cyberinfections.frih.net/uploads/yourfilename.ext'; ?> |
