Jump to content

accept form attribute not working


HaLo2FrEeEk

Recommended Posts

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

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.

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.

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.

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.

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.

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.