1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Copyright 2019 Amin Yazdanpanah<http://www.aminyazdanpanah.com>. |
||
5 | * |
||
6 | * Licensed under the MIT License; |
||
7 | * you may not use this file except in compliance with the License. |
||
8 | * You may obtain a copy of the License at |
||
9 | * |
||
10 | * https://opensource.org/licenses/MIT |
||
11 | * |
||
12 | * Unless required by applicable law or agreed to in writing, software |
||
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
15 | * See the License for the specific language governing permissions and |
||
16 | * limitations under the License. |
||
17 | */ |
||
18 | |||
19 | |||
20 | require_once '../vendor/autoload.php'; |
||
21 | |||
22 | use AYazdanpanah\SaveUploadedFiles\File; |
||
23 | use AYazdanpanah\SaveUploadedFiles\Validator; |
||
24 | use Gumlet\ImageResize; |
||
0 ignored issues
–
show
|
|||
25 | |||
26 | if(isset($_POST['submit'])) { |
||
27 | $image_path = __DIR__ . "/images/user/123456"; |
||
28 | $export_image = function ($filename) use ($image_path) { |
||
29 | //Add a Validator: check if the file is image |
||
30 | if (!is_type("image", $filename)) { |
||
31 | throw new Exception("Your file is not an image!"); |
||
32 | } |
||
33 | |||
34 | // Resize and crop your image |
||
35 | mkdir($image_path . "/thumbnail", 0777, true); |
||
36 | $image = new ImageResize($filename); |
||
37 | $image->resizeToWidth(50)->save($image_path . "/thumbnail/thumb_50.jpg"); |
||
38 | |||
39 | return exif_read_data($filename); |
||
40 | }; |
||
41 | |||
42 | $validator = new Validator(); |
||
43 | |||
44 | $validator = $validator->setMinSize(100) |
||
45 | ->setMaxSize(1024 * 3) |
||
46 | ->setType(['jpg', 'png', 'jpeg']); |
||
47 | |||
48 | $upload = new File(); |
||
49 | |||
50 | $upload = $upload->file('upload_image') |
||
51 | ->setValidator($validator) |
||
52 | ->setOverride(false) |
||
53 | ->setSaveAs('my_image') |
||
54 | ->save($image_path, $export_image); |
||
55 | |||
56 | var_dump("<pre>", $upload, "</pre>"); |
||
57 | } |
||
58 | ?> |
||
59 | |||
60 | <!DOCTYPE html> |
||
61 | <html> |
||
62 | <body> |
||
63 | ************************************************************************************************************************ |
||
64 | <form action="" method="post" enctype="multipart/form-data"> |
||
65 | Select an image: <input type="file" name="upload_image" id="upload_image"><br> |
||
66 | <input type="submit" value="Upload" name="submit"> |
||
67 | </form> |
||
68 | ************************************************************************************************************************ |
||
69 | |||
70 | </body> |
||
71 | </html> |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths