redarrow Posted October 2, 2008 Share Posted October 2, 2008 Advance thank you...... I am currently on a big project,at the end but i need to no what mime type is the most used for .exe files..... this is an example off all the mime types for .exe excutiable files..... application/octet-stream application/x-msdownload application/exe application/x-exe application/dos-exe vms/exe application/x-winexe application/msdos-windows application/x-msdos-program this is for a upload form so the user dosent get to post a .exe file..... current code not working! <?php $_FILES['usefile']['name']='redarrow.exe'; $x=array( "application/octet-stream", "application/x-msdownload", "application/exe", "application/x-exe", "application/dos-exe", "vms/exe", "application/x-winexe", "application/msdos-windows", "application/x-msdos-program" ); foreach($x as $b){ if ($_FILES['usefile']['type']==$b)die("You cannot upload exe files. I'm reporting you to the FCC!"); if (stristr($_FILES['usefile']['type'],'.exe'))die("You cannot upload exe files. I'm reporting you to the FCC!"); } ?> Link to comment https://forums.phpfreaks.com/topic/126773-solved-need-help-mime-types-cheers/ Share on other sites More sharing options...
F1Fan Posted October 2, 2008 Share Posted October 2, 2008 How is it "not working?" Any errors? Also, rather than using a loop to check the values in $x, why not just use the in_array() function? <?php if (in_array($_FILES['usefile']['type'],$x)) die('Nope!'); ?> Link to comment https://forums.phpfreaks.com/topic/126773-solved-need-help-mime-types-cheers/#findComment-655689 Share on other sites More sharing options...
redarrow Posted October 2, 2008 Author Share Posted October 2, 2008 This done it cheers........ <?php $_FILES['usefile']['name']='redarrow.exe'; $x=array( "application/octet-stream", "application/x-msdownload", "application/exe", "application/x-exe", "application/dos-exe", "vms/exe", "application/x-winexe", "application/msdos-windows", "application/x-msdos-program", ".exe" ); if( in_array($_FILES['usefile']['type'],$x) || substr($_FILES['usefile']['name'],-4)) die('Nope!'); ?> Link to comment https://forums.phpfreaks.com/topic/126773-solved-need-help-mime-types-cheers/#findComment-655711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.