Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $target = "E:PublicUpload/";
- $target = $target . basename( $_FILES['uploaded']['name']) ;
- $ok=1;
- $types = array('application/vnd.ms-excel', 'application/pdf', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
- //This is our size condition
- if ( ($_FILES["uploaded"]["size"] ) > 6291456)
- {
- echo "Your file is too large.<br>";
- echo "Your file is: " . ROUND(($_FILES["uploaded"]["size"] / 1024/1024),2) . " MB<br />";
- echo "Max File size is 5MB";
- $ok=0;
- }
- //Here we check that $ok was not set to 0 by an error
- elseif ($ok==0)
- {
- Echo "Sorry, your file was not uploaded";
- }
- //This is our limit file type condition
- elseif (in_array($_FILES["uploaded"]["type"] , $types))
- {
- if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
- {
- // echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded <br />";
- echo "File: " . $_FILES["uploaded"]["name"] . " has been uploaded <br />";
- // echo "Type: " . $_FILES["uploaded"]["type"] . "<br />";
- // echo "$uploaded_type": " . $uploaded_type . "<br />;
- echo "Size: " . ROUND(($_FILES["uploaded"]["size"] / 1024/1024),2) . " MB<br />";
- // echo "Location: Vendors/" . $_FILES["uploaded"]["name"] . " <br />";
- }
- else
- {
- echo "Sorry, there was a problem uploading your file, please make sure it is not a duplicate invoice.";
- }
- }
- else
- {
- Echo "Sorry your file was not uploaded. It may be the wrong file type or size. We only allow PDF, XLSX, and XLS files under 5MB.";
- }
- //If everything is ok we try to upload it
- /* else
- {
- echo "No PHP files<br>";
- $ok=0;
- } */
- ?>
Add Comment
Please, Sign In to add comment