[email protected] Posted November 19, 2006 Share Posted November 19, 2006 here is my upload code:[code]<html><form method='post' action='' enctype='multipart/form-data'> <input name="MAX_FILE_SIZE" value="999999999999" type="hidden"> Choose a file to upload <input name="uploadedfile" type="file"> <input name="submit" type="submit" value="Upload"><?php// notice bad file TYPES (but i want Extentions)$bad_types = array('application/x-php');//if they ARE bad, display errorif( in_array( $_FILES['uploadedfile']['type'], $bad_types ) ){ echo "That File type is not supported.";}else{//otherwise, upload!$target_path = "uploads/";$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded. here is the link to your file: <a href='uploads/". basename( $_FILES['uploadedfile']['name']). "'>". basename( $_FILES['uploadedfile']['name'])."</a><br>"; } else{ echo "Error!"; }}?></body> </html>[/code]and i want it to block EXTENTIONS (.php), NOT file types (application/x-php)please help? Link to comment https://forums.phpfreaks.com/topic/27800-block-extentions-not-types-in-uploading/ Share on other sites More sharing options...
haaglin Posted November 19, 2006 Share Posted November 19, 2006 Try this: [code]if(eregi('.php$', $_FILES['uploadedfile']['name'])) { echo "That File type is not supported.";}[/code]If you have more bad extensions you can write like this:[code]if(eregi('.php$|.php3$|.htm$|.html$', $_FILES['uploadedfile']['name'])) { echo "That File type is not supported.";}[/code] Link to comment https://forums.phpfreaks.com/topic/27800-block-extentions-not-types-in-uploading/#findComment-127226 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.