PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 28th, 2002, 04:21 PM
JeT JeT is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 28 JeT User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to JeT
Upload Script

I am upgrading an upload script I made a week ago. But this time I wanna make it so you can only upload cetain file types. How would I go about doing this?

Reply With Quote
  #2  
Old September 28th, 2002, 05:47 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: Upload Script

When they upload the file, have a look at the file extension to see if it is allowed or not. I'm guessing it would be something like this, but I'm no good with patterns:
php Code:
Original - php Code
  1.  
  2. <?php
  3. if (ereg("$[gif|bmp|jpg|jepg|png]", $_FILES['varname']['name']))
  4.  {
  5.   do stuff here
  6.  }
  7. ?>

Someone please correct that as necessary...

Reply With Quote
  #3  
Old September 29th, 2002, 12:38 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Upload Script

php Code:
Original - php Code
  1.  
  2. <?php
  3.    
  4.     $arr=array('jpg', 'png', 'gif', '...');
  5.    
  6.     $file=$_FILES['file']['filename'];
  7.     $dot=strrpos($file, '.');
  8.     $ext=substr($file, $dot+1);
  9.     $ext=strtolower($ext);
  10.    
  11.     if (in_array($ext, $arr)) {
  12.         //do stuff here
  13.     }
  14.    
  15. ?>

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Upload Script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway