0

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.

1
  • Would you mind posting what your form looks like that is being POSTed? Commented Apr 30, 2014 at 2:58

3 Answers 3

1

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

0

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.

0
0

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.