cs3mw
08-03-2008, 10:46 AM
Hi all is it possible to get the size of an image before the image is uploaded to the server without using javascript?
|
Click to See Complete Forum and Search --> : Get image size before upload cs3mw 08-03-2008, 10:46 AM Hi all is it possible to get the size of an image before the image is uploaded to the server without using javascript? auxone 08-03-2008, 11:04 AM If you are using a form to upload the image like this, <input id="upload" type="file" name="uploaded_file"> once the form is submitted but before you actually upload it you can do stuff like: if (($_FILES['uploaded_file']['size'] > 2048001)) { die ('File must be an image, and 2MB or less in size. No animated GIFs.'); } At that point I believe it is still in memory, and you must commit it to your file system in a manner such as: move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $uploadFilename) or die('Failed! Receiving directory has insuffiecient permissions.'); Sheldon 08-03-2008, 04:46 PM You can't get the file size with out it being uploaded. For the above $_FILES to get the size, as Auxone as said, it is in the servers /tmp directory, and has been uploaded. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |