1

In my project , there is a possibility to download/upload a backup of the project (with some configuration/images etc etc).

I have to accept only backups in .zip format (for the upload) , for this i used this code for check the format (client side and server side)

client side , with jQuery form

var ftype=$('#FileInput')[0].files[0].type;
switch(ftype){
      case 'multipart/x-zip':
      break;
      case 'application/zip':
      break;
      case 'application/x-zip-compressed':
      break;
      case 'application/x-zip':
      break;
      default: .... //error type
}

server side

switch(strtolower($_FILES['FileInput']['type'])){
      case  'multipart/x-zip':
      break;
      case  'application/zip':
      break;
      case  'application/x-zip-compressed':
      break;
      case  'application/x-zip':
      break; 
     default: exit("1");
 }

Every O.S has a different manner to recognize a .zip file (in fact in the switch there isn't the application/octet-stream case , and for this i decided to ask about this because a user tell me this problem).

So , the question is : where i can find a doc about this , or something where i can find a list of the various manner in which the O.S recognize a .zip file. thanks

WhiteLine
  • 1,919
  • 2
  • 25
  • 53
  • You shouldn't rely on the file type string transmitted by the browser at all; once uploaded, check the actual type of the file using a command that looks at its data, not its name. Remember that all information coming from the browser is untrusted, and trivial for users to set however they want. – IMSoP Mar 01 '15 at 13:38
  • Sure sure , in fact the control of the data of the zip file is done after the control of the type of the backup. I inserted this control to tell the user that the format of the backup is not compatible (if is compatible i can do the control of the data in the zip file). – WhiteLine Mar 01 '15 at 13:49
  • See http://stackoverflow.com/questions/10558251/php-allowed-zip-mimetypes – kuldeep.kamboj Mar 03 '15 at 10:19

0 Answers0