Support » Plugin: NextGEN Public Uploader » Need to be able to upload multiple images

Viewing 15 replies - 1 through 15 (of 18 total)
  • I need the same thing.

    I would love the same thing!!!!!!

    ditto!

    Maybe it’s not a very good solution, but it works for me.

    Solution:

    In file /nextgen-public-uploader/inc/npu-upload.php replace lines 201, 270.
    from:
    $strOutput .= "\n\t<input type=\"file\" name=\"imagefiles\" id=\"imagefiles\"/>";

    to:
    $strOutput .= "\n\t<input type=\"file\" name=\"imagefiles[]\" id=\"imagefiles\" multiple=\"multiple\" />";

    On line 488 replace:

    from:
    $this->handleUpload();

    to:

    $count = count((array)$_FILES['imagefiles']['tmp_name']);
    $x = $_FILES['imagefiles'];
    for($i=0; $i<$count; $i++){
    $_FILES['imagefiles']['name']= $x['name'][$i];
    $_FILES['imagefiles']['type']= $x['type'][$i];
    $_FILES['imagefiles']['tmp_name']= $x['tmp_name'][$i];
    $_FILES['imagefiles']['error']= $x['error'][$i];
    $_FILES['imagefiles']['size']= $x['size'][$i];
    $this->handleUpload();
    }

    On line 139 replace:

    from:
    $this->handleUpload_widget();

    to:

    $count = count((array)$_FILES['imagefiles']['tmp_name']);
    $x = $_FILES['imagefiles'];
    for($i=0; $i<$count; $i++){
    $_FILES['imagefiles']['name']= $x['name'][$i];
    $_FILES['imagefiles']['type']= $x['type'][$i];
    $_FILES['imagefiles']['tmp_name']= $x['tmp_name'][$i];
    $_FILES['imagefiles']['error']= $x['error'][$i];
    $_FILES['imagefiles']['size']= $x['size'][$i];
    $this->handleUpload_widget();
    }

    Thats all!

    Thats my file with multiples upload and gallery chooser: npu-upload.php

    Thank you for doing that!

    I’m getting an error at the top of the page that says they are not valid files but they still get uploaded to the gallery anyways.

    Better than nothing!

    dyabol – thank you for that solution. It works except when a person uploads 3 images, I get three emails and it uploads 9 photos to my gallery – each photo get uploaded three times.

    What am I doing wrong?

    Your help would be much appreciated.

    My apologies – this morning it works perfectly fine. I haven’t made any changes since last night so don’t know what is different! Point is, your solution works! Thank you very much!

    Hope you don’t mind but I posted a link to your solution on another forum.

    I will try that solution – thank you so much for sharing it, dyabol! 🙂

    It might not look pretty, but you can always add several instances of the shortcode to your page to produce multiple fields.

    When using this method it all works perfectly for what I want to do, but like Tasha I get multiple “Your image has been successfully uploaded” for every image in one bulk upload, and also emails for every image.

    So for example if someone uploaded 100 photos to my gallery, there is 100 “Success” messages spamming the website, and 100 emails notifying me of an upload. I would rather just have one email per bulk upload, and one message.

    Has anyone else had this problem, other than Tash, or know of a way to fix?

    Thank you

    I’ve extended the change to have multiple lines for each file so I can see what is being uploaded and it will only display single message and send single email for the upload:

    Assuming your line 205 looks like this:
    if (current_user_can('level_'. $npu_selected_user_role . '') || get_option('npu_user_role_select') == 99) {
    Replace everything between it and if (!$strDetailsPage) { below, including them, to:

    if (current_user_can('level_'. $npu_selected_user_role . '') || get_option('npu_user_role_select') == 99) {
    					$strOutput .= "<div id=\"uploadimage\">";
    					$strOutput .= "<script type=\"text/javascript\">";
    					$strOutput .= 'jQuery(function($){$("document").ready(function(){$("#addBtn").click(function() { var ncnt = parseInt($("#lastcnt").val())+1;var ninp=$("<br/><input type=\"file\" name=\"imagefiles[]\" id=\"imagefiles"+ncnt+"\" />");$("#UploaderDiv").append(ninp); });});});';
    					$strOutput .= "</script>";
    					$strOutput .= "\n\t<form name=\"uploadimage\" id=\"uploadimage_form\" method=\"POST\" enctype=\"multipart/form-data\" accept-charset=\"utf-8\" >";
    			   		$strOutput .= wp_nonce_field('ngg_addgallery', '_wpnonce', true , false);
    					$strOutput .= "\n\t<div id=\"UploaderDiv\" class=\"uploader\"><input type=\"hidden\" id=\"lastcnt\" value=\"1\" />";
    					$strOutput .= "\n\t<input type=\"file\" name=\"imagefiles[]\" id=\"imagefiles1\" />";
    					$strOutput .= "\n</div><br/><input type=\"button\" value=\"Add picture\" id=\"addBtn\">";
    					$strOutput .= "\n<input type=\"hidden\" name=\"galleryselect\" value=\"{$gal_id}\">";
    					if (!$strDetailsPage) {

    The same thing on line 277:

    if (current_user_can('level_'. $npu_selected_user_role . '') || get_option('npu_user_role_select') == 99) {
    					$strOutput .= "<div id=\"uploadimage\">";
    					$strOutput .= "<script type=\"text/javascript\">";
    					$strOutput .= 'jQuery(function($){$("document").ready(function(){$("#addBtn").click(function() { var ncnt = parseInt($("#lastcnt").val())+1;var ninp=$("<br/><input type=\"file\" name=\"imagefiles[]\" id=\"imagefiles"+ncnt+"\" />");$("#UploaderDiv").append(ninp); });});});';					$strOutput .= "</script>";
    					$strOutput .= "\n\t<form name=\"uploadimage_widget\" id=\"uploadimage_form_widget\" method=\"POST\" enctype=\"multipart/form-data\" accept-charset=\"utf-8\" >";
    			   		$strOutput .= wp_nonce_field('ngg_addgallery', '_wpnonce', true , false);
    			   		$strOutput .= "\n\t<div id=\"UploaderDiv\" class=\"uploader\"><input type=\"hidden\" id=\"lastcnt\" value=\"1\" />";
    					$strOutput .= "\n\t<input type=\"file\" name=\"imagefiles[]\" id=\"imagefiles1\"/>";
    					$strOutput .= "\n</div><br/><input type=\"button\" value=\"Add picture\" id=\"addBtn\">";
    					$strOutput .= "\n<input type=\"hidden\" name=\"galleryselect\" value=\"{$gal_id}\">";
    					if (!$strDetailsPage) {

    Then find if(get_option('npu_upload_success')) { around line 341 and replace it and everything in between to and including if (is_array($this->arrImageIds) && count($this->arrImageIds) > 0) { with:

    if(get_option('npu_upload_success')) {
    							if ($this->arrImageMsg[0] != get_option('npu_upload_success')){
    								$this->arrImageMsg[] = get_option('npu_upload_success');
    								$this->sendEmail();}
    						} else {
    							$this->arrImageMsg[] = "Thank you! Your image has been submitted and is pending review.";
    							$this->sendEmail();
    						}
    					}
    					if (is_array($this->arrImageIds) && count($this->arrImageIds) > 0) {

    If something is not working, here is an entire npu-upload.php you can just replace yours with:
    http://binbox.io/q3o54#xHeBQEft

    Hi dyabol
    i tried your solution but when i upload multiple image it gives error fatal error you can not redeclare operateImage() and only one image is uploading to my gallery please help me to resolve that error.

    Thanks

    Hello every one please help me in multiple upload i tried your solution but only one image is upload to gallery please help me with that code please any one pro can give me the solution of it plz help me its urgent…….

    thanks in advance

    Please help me!
    I’ve updated to new version but overwriting my npu-upload.php file. So I’ve lost my working multiple file choosing.

    Please where can I download previous pliugin version?
    Thanks

    @dado_it: Both methods seem to still work with the latest plugin and NextGen 2.X, however you will have to reapply the changes everytime you update the plugin.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Need to be able to upload multiple images’ is closed to new replies.