Comments (4)
You are trying to catch an exception which isn't thrown inside your code, or inside the bulletproof class. If you have seen the inside of bulletproof.php there are no exceptions being thrown so this won't show anything.
echo $e->getMessage(); // won't work
If you want to show exceptions instead of errors, then your exception block should look something like this:
try {
if($image['foo'] && $image->upload()){
//...
}else{
throw new \Exception($image['error']);
}
} catch (Exception $e) {
echo $e->getMessage();
}
Also, if you are seeing a blank page, make sure you have set errors to be displayed, or put this in your script.
error_reporting(E_ALL);
ini_set('display_errors', 1);
check these and let me know.
from bulletproof.
Can you please tell me a way to show error related to the size like "File uploaded is more than 5MB" when the uploaded file is more than 5 MB? As I have already set the hidden field "MAX_FILE_SIZE" value as 5000000
from bulletproof.
Okay, after some time I found the issue, this is most likely a bug with the newer version of bulletproof, as the previous version does not show this error. I have created a dev branch and added this code
https://github.com/samayo/bulletproof/blob/dev/src/bulletproof.php#L127-L129
Your code should look like this to show the error:
$image = new \Bulletproof\Image($_FILES);
if($image['pictures']){
// upload
}else{
var_dump($image['error']); // error will be shown here
}
make sure to download the dev branch or add those lines to your bulletproof class.
I will try to find a better way to handle this, and will leave this open until I fix the issue
from bulletproof.
It's working fine now. Thank you for the patch.
from bulletproof.
Related Issues (20)
- Minor improvements HOT 2
- Packagist version outdated? Util functions not found thru namespace? And other bugs. HOT 2
- How do i upload multiple image, rename and create thumbnail HOT 4
- File upload not working in linux server HOT 2
- How to Save in JPG (instead of JPEG)? HOT 4
- Svg upload ? HOT 2
- Bulletproof - change image that was uploaded HOT 9
- Upsizing not working HOT 7
- Error! directory 'bulletproof' could not be created
- Readme examples are referencing wrong methods (setLocation is now setStorage ) HOT 4
- Uploading Image From a URL HOT 1
- The README.md shows "setLocation" as a valid function, when said function has appearently been renamed to "setStorage" HOT 1
- Dependency Dashboard
- Constant 'FILTER_SANITIZE_STRING' is deprecated HOT 2
- setName fails to work... HOT 1
- Image format error HOT 9
- Object of class UnwindExit could not be converted to string HOT 3
- PHP Deprecated: Return type of Bulletproof\Image HOT 1
- uploaded image is missing a name
- setName() doesn't set the name for uploaded file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bulletproof.