PHP
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists PHP

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old June 17th, 2008, 09:11 AM
Dan Shirah
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
substr?

>
The code I'm having issues with is this:
>

$filename = $_FILES['userfile']['name']; // Get the name of the file
(including file extension).
$ext = substr($filename, strpos($filename,'.'),
strlen($filename)-1); // Get the extension from the filename.
>

All I want to do is grab the file extension and verify that it is a .zip or
a .pdf etc. file. This is working for small files (under a few megs) but for
some reason it fails when I get bigger. I have increased the allowed memory
size to 50 MB's I'm testing with a 44 MB file right now.


I'm not an expert on pulling in and reading files, but if all you want is
the last three characters of a file name, couldn't you just do something
like:

$extension = substr($filename, -3);

if ($extension = "pdf" || $extension = "zip") {
echo "The file is a PDF or ZIP.";
} else {
echo "Incorrect file type.";
}

??

maybe you are saying you want it to perform this check while the user is
attempting to upload the file and not after it has been uploaded?

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists PHP > substr?


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 Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT