WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Public Uploader
Need to be able to upload multiple images (19 posts)

  1. Ursula (aka WP Gal)
    Member
    Posted 1 year ago #

    This is an almost perfect solution for my client's needs, except that the plugin doesn't allow for multiple images to be uploaded. Is there an easy tweak to allow this at all?

    http://wordpress.org/extend/plugins/nextgen-public-uploader/

  2. buttons00
    Member
    Posted 1 year ago #

    I need the same thing.

  3. muss
    Member
    Posted 1 year ago #

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

  4. golden-eye
    Member
    Posted 1 year ago #

    ditto!

  5. dyabol
    Member
    Posted 1 year ago #

    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

  6. buttons00
    Member
    Posted 1 year ago #

    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!

  7. Tasha
    Member
    Posted 1 year ago #

    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.

  8. Tasha
    Member
    Posted 1 year ago #

    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.

  9. Ursula (aka WP Gal)
    Member
    Posted 1 year ago #

    I will try that solution - thank you so much for sharing it, dyabol! :)

  10. BuildsNetwork
    Member
    Posted 1 year ago #

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

  11. Poegle87
    Member
    Posted 1 year ago #

    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

  12. grizli12
    Member
    Posted 1 year ago #

    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

  13. jaybarad
    Member
    Posted 8 months ago #

    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

  14. jaybarad
    Member
    Posted 8 months ago #

    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

  15. dado_it
    Member
    Posted 8 months ago #

    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

  16. Mortus Eclipse
    Member
    Posted 7 months ago #

    @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.

  17. Mortus Eclipse
    Member
    Posted 7 months ago #

    I do have a question though. All the files seem to have a hash attached to the end of the filenames when they are uploaded. What is causing this?

  18. Mortus Eclipse
    Member
    Posted 7 months ago #

    NM, I found it in the class file... Not sure how I want to handle it yet though.

  19. nefar
    Member
    Posted 7 months ago #

    I agree that this functionality should already be built into the uploader along with a few other options.

    Props to dyabol for the multicode.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic