1

I have the following code and was wondering if it was possible to compress a a file over 2mb to a size under 2mb before uploading.

Thanks

if(isset($_FILES['file_array'])){
                $msg ="";
                $name_array = $_FILES['file_array']['name'];
                $tmp_name_array = $_FILES['file_array']['tmp_name'];
                $type_array = $_FILES['file_array']['type'];
                $size_array = $_FILES['file_array']['size'];
                $error_array = $_FILES['file_array']['error'];
                for($i = 0; $i < count($tmp_name_array); $i++){
                    if(move_uploaded_file($tmp_name_array[$i], $path."/".$name_array[$i])){
                        $msg .= $name_array[$i]." has been uploaded<br />";
                    } else {
                        echo "move_uploaded_file function failed for ".$name_array[$i]." ".$error_array[$i]."<br>";
                    }
                }
            }
  • not in php... the file has already been upload by the time php get a hold of it – Orangepill Aug 11 '15 at 16:26
  • http://stackoverflow.com/questions/10333971/html5-pre-resize-images-before-uploading might be a resource for resizing on the client via javascript prior to uploading – Orangepill Aug 11 '15 at 16:28

0 Answers0