Top

Upload File


PHP Code
+ 0 likes
Please Register to submit score.
Average Score  7.5
Scores Submitted  2
Date Added  Dec 31, 2006
Last Updated  May 28, 2007
Tags  avi  file  gif  jpg  upload 
  Bookmark and Share

Introduction

The instructions are in the code

Grab the Code

Comments

  (7)  RSS
tye
Comments: 67
 
PHP Snippet:  Upload File
Posted on Dec 31, 2006 11:56 pm
It\'s not always a good idea to rely on $_FILES[][\'type\'] because this is simply the MIME type the client browser has given. This can potentially be faked by a client and browsers can also report the incorrect MIME type or give a generic MIME type.

You can use the getimagesize() function to get the MIME type of an image:

list($x,$x,$mime_type) = getimagesize($_FILES[\'files\'][\'tmp_name\']);

if ($mime_type == \'image/jpeg\' || $mime_type == \'image/gif\' || $mime_type == \'image/png\') {
....
tye
Comments: 67
 
PHP Snippet:  Upload File
Posted on Dec 31, 2006 11:58 pm
There\'s also an error in your if statement that checks the type/size, it will accept a gif image of any size. It should be:

if ( (($_FILES[\"file\"][\"type\"] == \"image/gif\") || ($_FILES[\"file\"][\"type\"] == \"image/jpeg\")) && ($_FILES[\"file\"][\"size\"] < 20000))
peterpowell
Comments: 48
 
PHP Snippet:  Upload File
Posted on Apr 10, 2007 12:17 pm
/*
First make a php file called \'upload.htm\'
put the following code in it
*/

isnt that a html file if the extension is .htm

;)
Noutrious
Comments: 343
 
PHP Snippet:  Upload File
Posted on May 29, 2007 11:37 am
peterpowell, i think he removed part of the code.
ZabuzaMomochi
Comments: 186
 
PHP Snippet:  Upload File
Posted on May 29, 2007 3:30 pm
..Wtf happened? Why is everything gone..?
wizkidweb16
Comments: 6
 
PHP Snippet:  Upload File
Posted on Feb 1, 2008 8:12 pm
Yeah, the code just vanished. I really want this script.
Undefined_Variable
Comments: 5
 
PHP Snippet:  Upload File
Posted on Mar 8, 2008 12:51 am
It sounds like it was a really good script
the php probably got parsed and commented out or maybe it was seen as JavaScript. I don\'t know, but this seems like a really good script :D

Please Register or Login to start posting comments.
Bottom