Reputation: 1048
I have this very simple form. It's for people who want to give their selves a "profile picture" on my website. No upload, just put the url of your image and click save. So, it's just a "url".
This is my current code
<?PHP
if(is_array(getimagesize($_POST['profilepicture']))&&filter_var($_POST['profilepicture'], FILTER_VALIDATE_URL,FILTER_FLAG_SCHEME_REQUIRED)){
echo "Good";
} else {
echo "Bad";
}
?>
I have tried everything. I've tried just getimagesize() and it doesn't work. This works on my localhost via wamp, but fails on my host. Do I have to have something in my php.ini changed?
Thanks so much.
Upvotes: 0
Views: 403
Reputation: 764
It is possible that your host might not have the allow_url_fopen
directive enabled. This might cause the situation where external url's image not to be accessed by the getimagesize
function. If that is the case turning on error reporting will throw a warning stating
Warning: getimagesize(http://extenalsite.com/path/to/profile/image.txt) [function.getimagesize]: failed to open stream: no suitable wrapper could be found
and setting it on would help the cause. Refer similar question here
Upvotes: 1
Reputation: 1048
I've figured out the problem. I checked out my error log on my host. It said allow_url_fopen=0 was the error. I turned it "On" on my php.ini, and now it works!
Upvotes: 0
Reputation: 1005
Check your "upload_max_filesize" definition in your PHP.ini folder. Make sure it is not failing the upload procedure. (Any files larger than the default 2MB will be cancelled.)
For reference check out this thread.
Upvotes: 0