Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-20-2004, 04:19 PM   #1 (permalink)
NirTivAal
Registered User
 
Join Date: Oct 2003
Posts: 11
NirTivAal is on a distinguished road
File upload

OK, I think I understand this but I'd like to make sure I have it down before I let anyone upload files to my server.

First I have to create a form and use the tag <input type="file" name="something"> (and all those other form tags)

It will get passed on to $_FILES['something']['size' (or name, etc...)]

Now I have to use the function move_uploaded_file($_FILES['something']['size'], $directory) to get it into the correct location.

Also, is there any way that I can reject the file if it's not a jpeg, or convert it to jpeg if it's a wbmp?

Is this stuff all correct?
NirTivAal is offline   Reply With Quote
Old 02-20-2004, 05:35 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,505
sde is on a distinguished road
you can do a strstr($_FILE[0]['type'],".jpg") to test for .jpg

i don't know how you can convert it.

if your upload script doesn't work, let me know, i do have some code laying around here that i made recently. =)
__________________
Mike
sde is offline   Reply With Quote
Old 02-20-2004, 06:00 PM   #3 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
I also recently built a script to upload strictly image files (jpg|png|gif) and did it using an array with the MIME types compared against the value of $_FILES['file]['type'] ( or $_FILES[0]['type'] of course ).

example (excerpt from the real script)
PHP Code:
$allowed_types = array('image/png''image/jpeg''image/pjpeg''image/gif');
if ( !
in_array($_FILES['file']['type'], $allowed_types) )
{
    
// not the right MIME type, do something


Regarding converting the file type; are you talking about a wireless bitmap (WBMP) file or a windows bitmap (BMP) image file?
bdl is offline   Reply With Quote
Old 02-20-2004, 06:25 PM   #4 (permalink)
NirTivAal
Registered User
 
Join Date: Oct 2003
Posts: 11
NirTivAal is on a distinguished road
Honestly, I don't know. php.net keeps reffering to wbmp, which I assumed meant windows bitmap.

Also, it appears you can convert a jpeg to bitmap, but not the other way around.
NirTivAal is offline   Reply With Quote
Old 02-20-2004, 06:25 PM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,505
sde is on a distinguished road
oops my code example is badd .. you would have to take out the '.' lol.. bdl has it goin on =)
__________________
Mike
sde is offline   Reply With Quote
Old 03-02-2004, 01:29 PM   #6 (permalink)
Paultry
Registered User
 
Paultry's Avatar
 
Join Date: Mar 2004
Posts: 1
Paultry is on a distinguished road
If you want to convert another image type to a JPEG it's pretty easy to do using PHPs image functions as long as it's a bmp or png file.

Look up the Imagecreatefromxxxx() functions in the manual
Paultry is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File upload error(PHP) jacob PHP 8 08-16-2002 06:16 AM


All times are GMT -8. The time now is 03:53 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting