saradrungta Posted December 31, 2008 Share Posted December 31, 2008 how can i restrict user to upload on some type of files. eg. only image file. Link to comment https://forums.phpfreaks.com/topic/139024-file-uploading/ Share on other sites More sharing options...
rhodesa Posted December 31, 2008 Share Posted December 31, 2008 you could check the extension...but that isn't trustworthy, as they can just change the extension. if it's images specifically you want to check for, you can use: http://us.php.net/manual/en/function.getimagesize.php to see if it's a valid image Link to comment https://forums.phpfreaks.com/topic/139024-file-uploading/#findComment-727107 Share on other sites More sharing options...
peranha Posted December 31, 2008 Share Posted December 31, 2008 Get the type of file, and do a check to make sure it is a valid type. <?php $fileType = $_FILES['userfile']['type']; ?> Link to comment https://forums.phpfreaks.com/topic/139024-file-uploading/#findComment-727110 Share on other sites More sharing options...
CMC Posted December 31, 2008 Share Posted December 31, 2008 Here, download this PDF tutorial. I couldn't find the link (site is www.scanit.be) I originally downloaded it from so I just re-uploaded onto one of mine. When I created my first upload script I followed the security measures shown in the tutorial. Basically, the size, file headers, file extensions are checked. Here's the download http://www.flawclan.com/dc/?cat_id=misc&file_id=32 Link to comment https://forums.phpfreaks.com/topic/139024-file-uploading/#findComment-727188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.