Forum Moderators: coopster

Message Too Old, No Replies

uploading pdf files

how to upload a pdf files

         

watermelon

10:54 am on Jun 17, 2003 (gmt 0)

10+ Year Member



hi, i tried to do a upload script. now, i can upload any types of files. but, i want the system can only upload a pdf file. can anyone help? thank you.

Xuefer

12:21 pm on Jun 17, 2003 (gmt 0)

10+ Year Member



just check the filename in server side script! (e.g. php script)

jatar_k

3:48 pm on Jun 17, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Why not check for the file extension and unlink it if it doesn't match?

watermelon

3:55 pm on Jun 17, 2003 (gmt 0)

10+ Year Member



hi, i tried to put this coding:

$im = pdf;

if ($im==pdf) upload file ();

else {
echo "this is not a valid format";
}

The thing is, no matter what file it is, it can be uploaded into my folder. Should i write this:

$im = text/pdf;

Will this work?

jatar_k

4:48 pm on Jun 17, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



how about

if (substr [php.net]($_FILES['userfile']['name'],-4,4)!= ".pdf" ) {
echo "that is not a pdf file";
} else {
//do upload stuff
}
"userfile" is the field name for the upload box