bjorno43 / imagesecure Goto Github PK
View Code? Open in Web Editor NEWPHP Library to securely handle images uploaded by users
PHP Library to securely handle images uploaded by users
Warning: Creating default object from empty value in imgupload.class.php on line 292
The result is:
File: produto-01.jpeg is not an image. The file is removed!
Your images can be viewed here:
In the config file:
define("R_PATH", __DIR__);
define("F_PATH", R_PATH.'/assets/imagens/produtos');
define("H_FILE", true);
In the file imgupload.class
:
private function check_img_mime($tmpname)
{
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mtype = finfo_file($finfo, $tmpname);
$this->mtype = $mtype;
if (strpos($mtype, '/assets/imagens/produtos/') === 0)
{
return true;
}
return false;
finfo_close($finfo);
}
The database:
In the method ImageUpload::check_img_mime()
the closing of the fileinfo is after the return
statements.
I believe it should be before the if
statement of this method so that the fileinfo resource is effectively closed.
EDIT - solved the problem it was my fault. don't know how to delete the issue
I tried to test it on my server. Updated the configuration, created the database. This is the error log after attempting the first upload with a valid jpg:
[03-Jun-2020 15:36:17 UTC] PHP Warning: Creating default object from empty value in /home/dp3ndfkah1ii/public_html/ImageSecure/imgupload.class.php on line 44
[03-Jun-2020 15:36:17 UTC] PHP Fatal error: Uncaught Error: Call to a member function prepare() on null in /home/dp3ndfkah1ii/public_html/ImageSecure/imgupload.class.php:74
Stack trace:
#0 /home/dp3ndfkah1ii/public_html/ImageSecure/imgupload.class.php(234): ImageUpload->createTable()
#1 /home/dp3ndfkah1ii/public_html/ImageSecure/upload.php(7): ImageUpload->uploadImages(Array)
#2 {main}
thrown in /home/dp3ndfkah1ii/public_html/ImageSecure/imgupload.class.php on line 74
Your library was easy to setup, though I did expect to see more on the read me, but what has me puzzled is how I take advantage of GD resizing. The images can be far too big from the user. I tried adding a GD function to resize but I am getting grief with that. Can you help or add a resize feature to the script?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.