Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple File Upload #1

Open
vipers-web-design opened this issue Apr 1, 2019 · 0 comments
Open

Multiple File Upload #1

vipers-web-design opened this issue Apr 1, 2019 · 0 comments
Assignees

Comments

@vipers-web-design
Copy link

vipers-web-design commented Apr 1, 2019

I like it, I tried various filetypes the outputs were different. I even tried to fool your script and change the extension of an EXE file to a PNG file, and $r['fileinfo'] still returned "EXE (MZ: DOS / Windows)".

I'm having problems when I read from multiple [type="file"] inputs. I had to split $r['mimeinfo'] to just return the mimetype:

$fID = new FileIdentifier( $_FILES[ 'file' ][ 'tmp_name' ][ $key ] );
$IDr = $fID->getResult();
if ( $IDr ) {
  $mimeType = end( explode( ': ', $IDr[ 'mimeinfo' ] ) );
} else {
  print( json_encode( array( 'status' => 'danger', 'alertMsg' => 'Cannot detect signature for file: ' . $_FILES[ 'uploadimg' ][ 'name' ][ $key ], 'code' => 0 ) ) );
  exit();
}

It says the first file (presumably) because of having [$key] is invalid, even though when I tested it as a single file upload validating as an image, it came back valid.

if ( $mimeType !== 'image/jpeg' || $mimeType !== 'image/png' ) {
  // I've tried != and && in various combinations, still detects a real png image invalid.
  print( json_encode( array( 'status' => 'danger', 'alertMsg' => $_FILES[ 'uploadimg' ][ 'name' ][ $key ] . ' is not a true image', 'code' => 0 ) ) );
  exit();
}

And yes, I have this in a foreach() loop, the first thing I'm doing is making sure if the file is a PNG/JPEG/JPG, your script is "the nosy sibling" asking "Are you really?"

@Tinram Tinram self-assigned this Jul 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants