Support » Plugin: Install via URL » [Plugin: Install via URL] Issue caused by forcing the file extension in the URL to be .ZIP

  • Hi.

    I really like the idea of this plugin. It’s brilliant. And it really saves me time!

    A little problem I have with this plugin is that often times I need to install a plugin straight from Github. Well, the issue is that Github gives you a link to download a zip which look pretty much like this one:

    Notice there is no .ZIP extension at the end. So when I enter this URL, I get an error that only .ZIP files are accepted. But the funny thing is, that this is a ZIP file! But I know, there is no easy way to figure that out from the URL.

    I do have a suggestion though. You could take any URL that the user inputs and try to fetch only the headers. If it’s a ZIP file, there will be a MIME-Type header that is equal to application/zip or some similar variation (some more options for this MIME value). Then if the MIME type is of a different file type, let the user know that only ZIP files are allowed.

    I would love to help with this issue and contribute!
    Please let me know what you think of this issue.
    After all the plugin is great and this is the only downside of it. By fixing this issue it can be perfect!

    Thanks for reading!
    M. Chasen

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Zagal


    nice thought, actually it took me 5mins to solve the problem, because php5 offers finfo object. I did it like that:

    1. First I’ve changed compareExt function to this:

    function compareExt($url) {
    		//get file extension from url
    		$extension = self::getMime($url);
    		//check if mime headers = application/zip
    		if($extension == 'application/zip'):
    			return true;
    			return false;

    2. Than I’ve added getMime function, which uses finfo_buffer to get mime headers.

    function getMime($url) {
    		//get file from url
    		$file = file_get_contents($url);
    		//create finfo object with FILEINFO_MIME_TYPE as argument
    		$finfoObject = new finfo(FILEINFO_MIME_TYPE);
    		//return mime header
    		return $finfoObject->buffer($file);

    I’ll update the code as soon as possible. Thanks for an IDEA! 🙂

    Best regards,

    Those are great news!

    Thanks for implementing that! I’ll be testing it real soon, I’ll try to let you know if it works for me too.

    Thanks again!

    Plugin Author Zagal


    today I’ll code some functions allowing plugin to support some other archive extensions.

    best regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Install via URL] Issue caused by forcing the file extension in the URL to be .ZIP’ is closed to new replies.