Jump to content

validating uploads BEFORE uploading a non standard file type


HaLo2FrEeEk

Recommended Posts

Hey, I'm making an upload form for people to upload files in ppf and sppf format, the mime type of which is "application/octet-stream", the files are obviously non standard.  I need to be able to check that the file being uploaded is of the type sppf or ppf, only, nothing else, I am uploading using a POST form.  I know that I would use javascript and php to get all the characters after the last . (dot) and check that they are equal to either sppf or ppf, but also, I know that someone could create form on a remote server and use my upload url as the action of the form, effectively bypassing any blocks of upload type.  I also know that I could use php after the file is uploaded to discard it if it is not either a sppf or ppf file.  What I need to know is this, is there a way to do this before the file is uploaded, without javascript, could I have a middle step?  Right now I go directly from the form to upload (in a switch statement, I have default and upload) could I add validate to that switch statement?  I don't think that would work, becuase someone could still do it remotely.  Maybe I could, in the upload case of the switch statement, check that the userfile variable (being passed via POST method fromt he form) has the extension sppf or ppf, if it does, it uploads it, if not, it cancels.  Would this work, and if not, could someone please give me an alternative to avoid checking after the file is uploaded.  Thank you.

Since I am sending the file through POST, could I do a check in the upload part of my switch statement that gets the extension, (which is all I need to check, not the mime type, since it is non standard,) and checks if it is either sppf or ppf?  Could I do this, that way, if it is not sppf or ppf, I could cancel the script.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.