Re: substr?
| From: | tedd | Date: | Tue, 17 Jun 2008 17:14:48 +0000 |
| Subject: | Re: substr? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-275490@lists.php.net to get a copy of this message | ||
At 9:01 AM -0400 6/17/08, Dan Shirah wrote:
if ($extension == "pdf" || $extension == "zip") tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.comThe code I'm having issues with is this: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."; } ?? Or 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?$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.