Hopefully I can do this with php
I want to allow my clients to upload their pdf or video files to my server without giving them ftp login details.
Lets look at PDF's first:
This must be similar code to uploading an image - same thing really - just the checking must be different I guess?
This is what I have for the form:
I think that I have specified 10Mb and the max ( maybe that's a bit low ? )
Expand|Select|Wrap|Line Numbers
- /*
- * upload_fm.php
- *
- */
- <form name="main_fm" enctype ="multipart/form-data" action ='upload_check.php' method = 'POST'>
- <input type = 'hidden' name='upld' value="on">
- <input type="hidden" name ="MAX FILE SIZE" value="10000000">
- <b>Your PDF:</b><br>
- <input type="file" size="50" id = "u1" name="upLoad">
- <input type="submit" value="Upload PDF">
- </form>
I guess that I need to check somehow that it is a PDF and not some horrible virus program!
Then I need to move the file to a directory so that it can be access by another script to allow downloading.
Let's say that I want to put it on /MyPDF directory so the path will be
/MyPDF/nameofPDF.pdf
Would really appreciate any help
Expand|Select|Wrap|Line Numbers
- /*
- * upload_check.php
- *
- */
- $N_pdf = $_FILES['upLoad']["name"];
- // possible PHP upload errors
- $errors = array(1 => 'php.ini max file size exceeded',
- 2 => 'html form max file size exceeded',
- 3 => 'file upload was only partial',
- 4 => 'no file was attached');
- if ($_FILES['upLoad']['error'] != 0) {
- $message1 = "PDF file did not successfully upload" ;
- $message2 = "Error: ".$errors[$_FILES['upLoad']['error']];
- require_once ("upload_fm.php");
- exit();
- } // endif
Thanks for any input