php - restrict image upload in uploadify -


i using uploadify upload images . there way restrict user upload other image width:670px height:200px. here uploadify.php code

<?php require_once("includes/connection.php");  $targetfolder = '/workbench/sudeepc/photogallery/uploads' ;   if (!empty($_files)) {     $tempfile = $_files['filedata']['tmp_name'];     $targetpath = $_server['document_root'] . $targetfolder;     $targetfile = rtrim($targetpath,'/') . '/' . $_files['filedata']['name'];      // validate file type     $filetypes = array('jpg','jpeg','gif','png'); // file extensions     $fileparts = pathinfo($_files['filedata']['name']);      if (in_array($fileparts['extension'],$filetypes)) {         move_uploaded_file($tempfile,$targetfile);   $query="insert `photo` ( `id` , `path` , `uname` )  values (  '','${targetfile}', 'testnn');";  mysql_query($query,$connection);       } else {         echo 'invalid file type.';     } } ?> 

thanks in advance .

there no way can restrict actual upload - file have uploaded in order server side logic test it's validity - file extension, dimensions, etc...

there built in php function determine image sizes - http://php.net/manual/en/function.getimagesize.php

getimagesize() 

the getimagesize() function determine size of given image file , return dimensions along file type , height/width text string used inside normal html img tag , correspondant http content type.
...
returns array 7 elements.
index 0 , 1 contains respectively width , height of image.

after have checked file extension, can call function on image , test it's dimensions against requirements.

here example output of function -

array (    [0] => 84 // width   [1] => 52 // height   ...  ) 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -