Jump to content

Uploading Files


steve-t

Recommended Posts

you could put the extensions into an array and some variables

[code]$limit_ext = "yes"; //do you want to limit the extensions of files uploaded
$ext_count = "2"; //total number of extensions in array below
$extensions = array(".pdf", ".ppt"); //List extensions you want files uploaded to be[/code]

Then check if they fall into the array
[code]$ext = strrchr($file_name,'.');
if (($limit_ext == "yes") && (!in_array($ext,$extensions))) {
echo "File is wrong type";
}else{
// place your code here

}
?>[/code]

Ray
Link to comment
https://forums.phpfreaks.com/topic/29005-uploading-files/#findComment-132880
Share on other sites

I thought that was a server thing, but after looking at the manual, I guess not, maybe this:
[CODE]
<?php
function file_extension($filename)
{
    $path_info = pathinfo($filename);
    return $path_info['extension'];
}
if(file_extension($_FILES['name'])=="PDF" || file_extension($_FILES['name'])=="PPT"){
//upload file
}else{
//dont upload
}?>[/CODE]
Link to comment
https://forums.phpfreaks.com/topic/29005-uploading-files/#findComment-132912
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.