![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 |
|
Senior Coder ![]() Join Date: Jan 2005
Location: Mauchline, Scotland
Posts: 1,043
Thanks: 15
Thanked 1 Time in 1 Post
![]() |
PHP Code:
Code:
<input type="file" name="filename" id="filename" class="textbox" size="40"> I know that the code isn't safe enough to put up live at the moment....... Cheers, Picco
__________________
Ayrshire Minis - a Mini E-Community | Ballochmyle Web Solutions | Follow Me on Twitter |
|
|
|
|
|
PM User | #2 |
|
Moderator ![]() ![]() Join Date: Mar 2007
Location: Florida, USA
Posts: 2,529
Thanks: 1
Thanked 222 Times in 215 Posts
![]() ![]() |
You can check if the image is valid by creating an image pointer with it via imagecreatefromjpeg() for example if it is a jpeg, and testing the return.
PHP Code:
|
|
|
|
|
|
PM User | #3 |
|
Regular Coder ![]() Join Date: Sep 2007
Location: Grahamstown, South Africa
Posts: 125
Thanks: 5
Thanked 7 Times in 7 Posts
![]() |
image validation
To make sure that it is an image you can try using getimagesize on the uploaded image, or you can try using this little stunner:
PHP Code:
|
|
|
|
|
|
PM User | #4 |
|
Senior Coder ![]() Join Date: Jan 2005
Location: Mauchline, Scotland
Posts: 1,043
Thanks: 15
Thanked 1 Time in 1 Post
![]() |
thanks for those replies, however I noticed that the first example is using imagecreatefromjpeg. Which i take it would only work if the image uploaded was infact a .jpg file.
The second example is using $mime_type which looks good, but is that a built-in PHP function? Picco
__________________
Ayrshire Minis - a Mini E-Community | Ballochmyle Web Solutions | Follow Me on Twitter |
|
|
|
|
|
PM User | #5 |
|
Master Coder ![]() Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 6,378
Thanks: 40
Thanked 479 Times in 468 Posts
![]() ![]() ![]() ![]() ![]() |
Use imagecreatefromgif() and imagecreatefrompng() as well. (Windows BMP files will require a 3rd party function which you can download from JPEXS).
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|