Viewed   64 times

Here is my current code:

$files = glob("*.jpg");

This works fine. However, I am wanting to list other image types, such as .png, gif etc.

Can I please have some help to modify this above code to get it working. I have tried the following with no success:

$files = glob("*.jpg","*.png","*.gif");

$files = glob("*.jpg,*.png,*.gif);

And other variations...

 Answers

4
$files = glob("*.{jpg,png,gif}", GLOB_BRACE);
Monday, November 21, 2022
5

Here's what worked best for me when trying to script this (in case anyone else comes across this like I did):

$ pecl -d php_suffix=5.6 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.0 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.1 install <package>
$ pecl uninstall -r <package>

The -d php_suffix=<version> piece allows you to set config values at run time vs pre-setting them with pecl config-set. The uninstall -r bit does not actually uninstall it (from the docs):

vagrant@homestead:~$ pecl help uninstall
pecl uninstall [options] [channel/]<package> ...
Uninstalls one or more PEAR packages.  More than one package may be
specified at once.  Prefix with channel name to uninstall from a
channel not in your default channel (pecl.php.net)

Options:
  ...
  -r, --register-only
        do not remove files, only register the packages as not installed
  ...

The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).

Monday, December 12, 2022
1

When you create your FormData object, you should pass the form to the constructor to get it populated with the forms values. You can then append the action value to that result:

var frm = document.getElementById(action_name + '_form');
var form_data = new FormData(frm);
form_data.append('action', action_name);

When you do it this way you should see $_POST and $_FILES populated correctly in your PHP code.

Friday, September 16, 2022
 
1

To allow the upload of multiple files I usually use uploadify It's documentation is fairly good, and it's pretty simple to use.

You need to use something like this in order to keep the connection open and send the files without reloading the page.

EDIT:

Your code should be something like this:

<script type="text/javascript">
$(function() {
    $('#custom_file_upload').uploadify({
        'uploader'       : 'JS/uploadify.swf',
        'script'         : 'JS/uploadify.php',
        'cancelImage'      : 'JS/uploadify-cancel.png',
        'multi'          : true,
        'auto'           : true,
        'fileTypeExts'        : '*.jpg',
        'fileTypeDesc'       : 'Image Files (.JPG)',
        'queueID'        : 'custom-queue',
        'queueSizeLimit' : 3,
        'simUploadLimit' : 3,
        'sizeLimit'   : 10240000,
        'removeCompleted': false,
        'onDialogClose'   : function(queue) {
            $('#status-message').text(queue.filesQueued + ' files have been added to the queue.');
        },
        'onQueueComplete'  : function(stats) {
            $('#status-message').text(stats.successful_uploads + ' files uploaded, ' + stats.upload_errors + ' errors.');
        }
    });             
});
</script>

swf changed to uploader and uploader changed to script.

Wednesday, August 10, 2022
 
4

Never used any of those, but they look interesting..

Take a look at Gearman as well.. more overhead in systems like these but you get other cool stuff :) Guess it depends on your needs ..

Friday, November 11, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :