HaLo2FrEeEk Posted April 22, 2007 Share Posted April 22, 2007 I cannot get my accept attribute working properly inside either my form, or my input tag. W3schools says that accept is supposed to go inside the input tag, but msdn says it goes in the form tag. I need it for an upload form I'm making, I want to only allow application/octet-stream type files, so I put this as my opening form tag: <form enctype="multipart/form-data" accept="application/octet-stream" action="{$_SERVER['PHP_SELF']}" method="POST"> But I can still upload music, text files, and movies. What gives? Link to comment https://forums.phpfreaks.com/topic/48097-accept-form-attribute-not-working/ Share on other sites More sharing options...
neel_basu Posted April 22, 2007 Share Posted April 22, 2007 But I can still upload music, text files, and movies. What gives?All of them can be treated as octet stream. even if your send some wrong headers to your browser some browsers will treat it as octet stream. Check the file type or mime type of the uploaded / being uploaded file on server side. Link to comment https://forums.phpfreaks.com/topic/48097-accept-form-attribute-not-working/#findComment-235117 Share on other sites More sharing options...
jchemie Posted April 22, 2007 Share Posted April 22, 2007 Well one of the best ways to do it is check the file extensions on the server side. So that it allows only the extensions you require. Thanks Jyot Link to comment https://forums.phpfreaks.com/topic/48097-accept-form-attribute-not-working/#findComment-235256 Share on other sites More sharing options...
HaLo2FrEeEk Posted April 22, 2007 Author Share Posted April 22, 2007 Any mp3 file can be renamed to something allowable, so that is unreliable, and I am checking the MIME type on the server side, I said to only allow octet-stream's but when I upload a text file, it says text/plain, when I upload a wma, it says audio/x-ms-wma, but it still allows it. Link to comment https://forums.phpfreaks.com/topic/48097-accept-form-attribute-not-working/#findComment-235562 Share on other sites More sharing options...
neel_basu Posted April 23, 2007 Share Posted April 23, 2007 Any mp3 file can be renamed to something allowable, so that is unreliable, and I am checking the MIME type on the server side, I said to only allow octet-stream's but when I upload a text file, it says text/plain, when I upload a wma, it says audio/x-ms-wma, but it still allows it. As far I know MIME Type depends on your Extension not on the binary / Text bit pattern of your File. try this and make sure about it. Rename a .mp3 file to .zip and then echo its mime type with php. And send the result. Link to comment https://forums.phpfreaks.com/topic/48097-accept-form-attribute-not-working/#findComment-235758 Share on other sites More sharing options...
HaLo2FrEeEk Posted April 23, 2007 Author Share Posted April 23, 2007 Ok, I renamed Here Without You,wma, by 3 Doors Down to Here Without You.zip and uploaded it, the MIME type it returned was application/octet-stream, then I uploaded the file in wma format (un-renamed) and the MIME type it returned was audio/x-ms-wma. The zip file should have returned either application/zip or application/x-zip-compressed. Link to comment https://forums.phpfreaks.com/topic/48097-accept-form-attribute-not-working/#findComment-235778 Share on other sites More sharing options...
boo_lolly Posted April 23, 2007 Share Posted April 23, 2007 Ok, I renamed Here Without You,wma, by 3 Doors Down to Here Without You.zip and uploaded it, the MIME type it returned was application/octet-stream, then I uploaded the file in wma format (un-renamed) and the MIME type it returned was audio/x-ms-wma. The zip file should have returned either application/zip or application/x-zip-compressed. i think that's what neel was saying. no matter what, it will handle the file as an octet-stream. if the extension is provided, it will simply give information about the type of file, but handle it the same. Link to comment https://forums.phpfreaks.com/topic/48097-accept-form-attribute-not-working/#findComment-235781 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.