Jump to content

Uploading photos... pre-upload verification?


LordLanky

Recommended Posts

Hi Guys,

 

basically - on my site i let users upload photos. One thing i've noticed though is that evaluating the file is done after the file is uploaded. Does anyone know, for example, how to evaluate the file size and extension of a file BEFORE the user has sent it? i'm assuming ajax (i hate ajax).

 

For example, a common approach to Denial of Service is to upload a 10 gig file to a site and kill its bandwidth (as sites tend to be limited to upload, but not download).

 

Any help, tips, advice, corrections to my feable understanding of all things technical, are most welcome!

 

 

Link to comment
Share on other sites

Read this:

http://us2.php.net/manual/en/features.file-upload.post-method.php

 

"i hate ajax": Do you even know what ajax is? And no, Ajax wouldn't be able to help you in determing the filesize as it would just like your form upload it to the server and then the server would evaluate it and return that size in JSON or some other format.

Link to comment
Share on other sites

As PHP is server side, the file will need to be uploaded before PHP can touch it,

 

You can tell the server to stop accepting files over X size by reducing the upload_max_filesize and post_max_size directives in the PHP.INI file,

for example if they are set to 2Mb then after 2Mb's are sent the upload is aborted.

 

If you want a client side validation, you maybe want to look at something like SWFuploader,

 

EDIT: Note: AJAX is JavaScript, and can't touch client files for security reasons

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.