Skip to content

Instantly share code, notes, and snippets.

@davewardle
Last active July 11, 2017 15:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save davewardle/e7eb0455c25e286f3b849ef5036df268 to your computer and use it in GitHub Desktop.
File upload
<?php
if (
$_FILES['file']['size'] > 0 &&
is_uploaded_file( $_FILES['file']['tmp_name'] ) &&
preg_match( '/\.(jpe?g|gif|bmp|png)$/i', $_FILES['file']['name'], $m )
) {
// ..
$original_name = $original_name . intval( $artwork_id );
$name_template = $name_template . intval( $artwork_id );
// ...
$output = $original_name.'.jpg'; // the original file
$preview = $name_template.'.preview.jpg'; // the modified files
move_uploaded_file( $_FILES['file']['tmp_name'], $output );
$command = "$convert_location $output -resize 200x200 $preview";
exec( $command );
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment