![]() |
|
|||||||
| View Poll Results: How complex is my code? | |||
| Not Very. |
|
1 | 50.00% |
| A little. |
|
0 | 0% |
| Average. |
|
1 | 50.00% |
| Complex. |
|
0 | 0% |
| Really complex how did you figure that out? |
|
0 | 0% |
| Voters: 2. You may not vote on this poll | |||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
How Do i get php to find out the file type of a file for me?I am trying to get php to determane the file type for me so i can just put in the file name and php tells me the file type. this is the code i have so far:
<html> <head> <title>Dodge Viper</title></head> <body> <?php $size = getimagesize ("dodge/viper/VIPER343.bmp"); if ( $size[2] == "2" ) { $size[2]="jpg"; } else { $size[2]="bmp"; } echo "<img src=\"dodge/viper/VIPER343.{$size[2]}\" {$size[3]}>"; ?> </body></html> But as you can see i have to put the file type in is there a way i can get php to find the file type out for me? Thank you |
|
#2
|
||||
|
||||
|
Read first then have a look here:http://dev.dave.imarc.net/fileupload/README.txt
I am not the most knowledgeable about php yet but I found this readme for a php class named fileupload which you can find here:http://dave.imarc.net/php/ Basically the readme says that the class can determine the file type so maybe you can look through the class and see how it is done. Its a bit of a longshot but it may help. |
|
#3
|
||||
|
||||
|
Hi viperman,
I don't really see the point for you to match the image type at this point of your script. After all, the function getimagesize() actually returns FALSE if the file it's processing is in error or not a valid image file! I think something like this should work, unless you haven't actually told us what is it exactly that you're trying to achieve here... PHP Code:
n.b. Some important additions are now available with this function in PHP 4.3+ __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
Recent GIDBlog
A Week in Kuwait by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP in HTML | jrobbio | Web Design Forum | 4 | 24-Jul-2003 06:05 |
| [script] Password Protect web pages/site using PHP and MySQL | JdS | PHP Code Library | 0 | 23-Jul-2003 10:02 |
| All the big PHP script collections that matter | jrobbio | MySQL / PHP Forum | 5 | 06-Jun-2003 16:14 |
| How do I find the Unix log file route? | jrobbio | Web Hosting Forum | 4 | 04-Feb-2003 07:40 |
| VALIDATING file types on an PHP upload script? | JdS | MySQL / PHP Forum | 0 | 02-Jan-2003 07:58 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The