WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Public Uploader
[resolved] Error displayed Upon Upload - "xxx.jpg is not a valid file". (17 posts)

  1. iBusinessLogic
    Member
    Posted 1 year ago #

    Public uploader seems to be working fine, other than this pesky error message that occurs when a user uploads a single file.

    No matter what file extension is uploaded (.jpg,.png,.gif) - Upon upload of an image, the following error message is repeated 7 times (In a large red info box at the top of the page) when the page where the short code is displayed reloads.

    "xxx.jpg" is not a valid file.

    The file uploads fine, and I am notified of the upload in email. I can then approve the image and it appears in the assigned gallery perfectly.

    I can find no where to select the "Authorized" file types for upload. I have tried disabling all other plugins in my installation to determine is there is a conflict.

    Any suggestions - ideas? Is this a new bug?

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

  2. capotea
    Member
    Posted 1 year ago #

    I have the same along with my reported error "invalid argument supplied foreach() .... /npu-upload.php on line 469".

    A few weeks ago these errors were not there, so it's recent.

    I had no support for that until now unfortunately.
    I hope someone comes up with an answer.

  3. iBusinessLogic
    Member
    Posted 1 year ago #

    Yes, this is a feature that would be very valuable to the site I am working on now. I cannot find the error. Any updates from the developer would be very welcome!

  4. Tanesi
    Member
    Posted 1 year ago #

    Save
    Information that might help.
    On my site had the same problem, looked for a solution, found nothing, either in support of Nextgen (use the public uploader)
    This week effected a fix in Apache, the problem stopped
    By searching I found that many sites are having the same problem
    sorry my english, I'm using a translator

  5. capotea
    Member
    Posted 1 year ago #

    Hi Tanesi,

    Can you tell about the fix in Apache?

    Your English is OK :-)

  6. iBusinessLogic
    Member
    Posted 1 year ago #

    Hopefully Tanesi's clues will help the developer find the issue and effect an update.

  7. ticneo
    Member
    Posted 1 year ago #

    The error occurs when I have activated the Jetpack for WordPress.com. If you do not see the Jetpack disable error uploading image with NextGen Public Uploader. Sorry for my english.

  8. ticneo
    Member
    Posted 1 year ago #

    Trying to activate and deactivate all plugins I've seen the error Jetpack. Specifically when I activate the plugin Jetpack email subscriptions I get the error uploading an image with Nextgen Public Uploader. When you disable this feature, the error disappears. Again, sorry for my English. Greetings.

  9. mariogroleau
    Member
    Posted 1 year ago #

    I have the same error, when users upload image, any image, the "xxx.jpg is not a valid file" is displayed at the begining of the page, but the image is correctly uploaded. My user are worry and retry uploading file many times.

    I also have jetpack activated.
    If jetpack is not activated, we have no error.

  10. Allastra
    Member
    Posted 1 year ago #

    I'm having the same problem, however I do not have Jetpack enabled.

  11. mariogroleau
    Member
    Posted 1 year ago #

    An update of the JetPack arrived and the problem disapear?

  12. Allastra
    Member
    Posted 1 year ago #

    i activated the updated Jetpack and I am still having the same error.

    Doctor+Who+Valentine_c53894_4430284.jpg is not a valid file.

    Warning: Invalid argument supplied for foreach() in [npu-upload.php path] on line 469
    Doctor+Who+Valentine_c53894_4430284.jpg is not a valid file.

    Warning: Invalid argument supplied for foreach() in [npu-upload.php path] on line 469

    at header

    Doctor+Who+Valentine_c53894_4430284.jpg is not a valid file.

    Warning: Invalid argument supplied for foreach() in [/npu-upload.php file path] on line 469

    above gallery on page

    You must select a file to uploadYou must select a file to uploadYou must select a file to upload
    Your File Has been added successfully

    before uploader form

    also note that the line given must be created as part of the loop as there is no line 469 in that file.

  13. Allastra
    Member
    Posted 1 year ago #

    Hey all,

    I've got it down to it's echoing out an error even though it's uploading the file fine.

    No file has been selected. Please select a file first before hitting the upload button.No file has been selected. Please select a file first before hitting the upload button.No file has been selected. Please select a file first before hitting the upload button.

    pops up right before my success message... why is it repeating a million times and where might i find the code that echos this.

  14. Allastra
    Member
    Posted 1 year ago #

    Nevermind i've got it working now :) Thanks sometimes it just helps talking stuff out while i work :) (there are echo statements all over npu-uploader, removing them so they only returned if there was an error helped :)

  15. jacobmclaws
    Member
    Posted 1 year ago #

    Allastra,

    could you give me a little more detail on how you got it to work. Some of my users are running into the problem of
    ____________ is not a valid file.
    Warning: Invalid argument supplied for foreach() in [/npu-upload.php file path] on line 469
    ?

    I just launched and now it stopped working and people are showing me this invalid stuff... :(

    Thanks

  16. arosstyler
    Member
    Posted 1 year ago #

    I have the same issue and have discovered it is tied to the shortcode uploader when using a specific gallery id. if I use [ngg_uploader id=1] or something with the id every file uploaded returns "is not a valid file" if I just use [ngg_uploader] then I get the success message and no error message.

    Since I don't want my users to upload every image into one default gallery I need this solved.

    Allstra I really wish you would post your npu_upload.php file for us as I am not a coder and can't find the echo's (hell I don't even know how to spot one). Any help here guys would be awesome for those of us stuck on this one.

  17. Allastra
    Member
    Posted 1 year ago #

    Not sure, as it turns out its not exactly working. I've still got an error coming up, though i think it's because the file is too large.

    Though the _____ is not a valid file was never an error I was getting...

    here's my class.npu_uploader.php file, hope it helps

    <?php
    
    // Get NextGEN Gallery Functions
    require_once (NGGALLERY_ABSPATH."/admin/functions.php");
    
    class UploaderNggAdmin extends nggAdmin
    {
    	// Public Variables
        public $arrImageIds = false;
        public $strGalleryPath = false;
        public $arrImageNames = false;
        public $strFileName = false;
        public $blnRedirectPage = false;
        public $arrThumbReturn = false;
        public $arrEXIF = false;
    	public $arrErrorMsg = array();
    	public $arrErrorMsg_widg = array();
    
        function upload_images() {
            global $wpdb;
            // Image Array
            $imageslist = array();
            // Get Gallery ID
            $galleryID = (int) $_POST['galleryselect'];
            if ($galleryID == 0) {
    			if(get_option('npu_default_gallery')) {
    				$galleryID = get_option('npu_default_gallery');
    			} else {
                	nggGallery::show_error(__('No gallery selected.','nggallery'));
    				return;
    			}
            }
            // Get Gallery Path
            $gallerypath = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE gid = '$galleryID' ");
            if (!$gallerypath){
                nggGallery::show_error(__('Failure in database, no gallery path set.','nggallery'));
                return;
            }
            // Read Image List
            $dirlist = $this->scandir(WINABSPATH.$gallerypath);
            foreach ($_FILES as $key => $value) {
                if ($_FILES[$key]['error'] == 0) {
                    $entropy = '';
                    $temp_file = $_FILES[$key]['tmp_name'];
                    $filepart = pathinfo ( strtolower($_FILES[$key]['name']) );
                    // Required Until PHP 5.2.0
                    $filepart['filename'] = substr($filepart["basename"],0 ,strlen($filepart["basename"]) - (strlen($filepart["extension"]) + 1) );
                    // Random hash generation added by [http://www.linus-neumann.de/2011/04/19/ngg_pu_patch]
                    	$randPool = '0123456789abcdefghijklmnopqrstuvwxyz';
    					for($i = 0; $i<20; $i++)
    						$entropy .= $randPool[mt_rand(0,strlen($randPool)-1)];
                    $filename = sanitize_title($filepart['filename']) . '-' . sha1(md5($entropy)). '.' .$filepart['extension'];
                    // Allowed Extensions
                    $ext = array('jpeg', 'jpg', 'png', 'gif', 'tiff', 'bmp' );
                    if ( !in_array($filepart['extension'], $ext) || !@getimagesize($temp_file) ){
                        //nggGallery::show_error('<strong>'.$_FILES[$key]['name'].' </strong>'.__('is not a valid file.','nggallery'));
                        continue;
    				}
                    // Check If File Exists
                    $i = 0;
                    while (in_array($filename,$dirlist)) {
                        $filename = sanitize_title($filepart['filename']) . '_' . $i++ . '.' .$filepart['extension'];
                    }
                    $dest_file = WINABSPATH . $gallerypath . '/' . $filename;
                    // Check Folder Permissions
                    if (!is_writeable(WINABSPATH.$gallerypath)) {
                        //$message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), WINABSPATH.$gallerypath);
                        nggGallery::show_error($message);
                        return;
                    }
                    // Save Temporary File
                    if (!@move_uploaded_file($_FILES[$key]['tmp_name'], $dest_file)){
                       // nggGallery::show_error(__('Error, the file could not moved to : ','nggallery').$dest_file);
                        $this->check_safemode(WINABSPATH.$gallerypath);
                        continue;
                    }
                    if (!$this->chmod ($dest_file)) {
                       // nggGallery::show_error(__('Error, the file permissions could not set.','nggallery'));
                        continue;
                    }
                    // Add to Image and Dir List
                    $imageslist[] = $filename;
                    $dirlist[] = $filename;
                }
            }
            if (count($imageslist) > 0) {
    			if ( ! get_option('npu_exclude_select')  ) {
    				$npu_exclude_id = 0;
    			} else {
    				$npu_exclude_id = 1;
    			}
                // Add Images to Database
                $image_ids = $this->add_Images($galleryID, $imageslist);
                $this->arrThumbReturn = array();
                foreach ($image_ids as $pid) {
                    $wpdb->query("UPDATE $wpdb->nggpictures SET exclude = '$npu_exclude_id' WHERE pid = '$pid'");
                    $this->arrThumbReturn[] = $this->create_thumbnail($pid);
                }
                $this->arrImageIds = array();
                $this->arrImageIds = $image_ids;
                $this->arrImageNames =array();
                $this->arrImageNames = $imageslist;
                $this->strGalleryPath = $gallerypath;
            }
            return;
        } // End Function
    
    	function upload_images_widget() {
            global $wpdb;
            // Image Array
            $imageslist = array();
            // Get Gallery ID
            $galleryID = (int) $_POST['galleryselect'];
            if ($galleryID == 0) {
    			if(get_option('npu_default_gallery')) {
    				$galleryID = get_option('npu_default_gallery');
    			} else {
                	//nggGallery::show_error(__('No gallery selected.','nggallery'));
    				return;
    			}
            }
            // Get Gallery Path
            $gallerypath = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE gid = '$galleryID' ");
            if (!$gallerypath){
               // nggGallery::show_error(__('Failure in database, no gallery path set.','nggallery'));
                return;
            }
            // Read Image List
            $dirlist = $this->scandir(WINABSPATH.$gallerypath);
            foreach ($_FILES as $key => $value) {
                if ($_FILES[$key]['error'] == 0) {
                    $temp_file = $_FILES[$key]['tmp_name'];
                    $filepart = pathinfo ( strtolower($_FILES[$key]['name']) );
                    // Required Until PHP 5.2.0
                    $filepart['filename'] = substr($filepart["basename"],0 ,strlen($filepart["basename"]) - (strlen($filepart["extension"]) + 1) );
                    $filename = sanitize_title($filepart['filename']) . '.' . $filepart['extension'];
                    // Allowed Extensions
                    $ext = array('jpeg', 'jpg', 'png', 'gif');
                    if ( !in_array($filepart['extension'], $ext) || !@getimagesize($temp_file) ){
                        //nggGallery::show_error('<strong>'.$_FILES[$key]['name'].' </strong>'.__('is not a valid file.','nggallery'));
                        continue;
    				}
                    // Check If File Exists
                    $i = 0;
                    while (in_array($filename,$dirlist)) {
                        $filename = sanitize_title($filepart['filename']) . '_' . $i++ . '.' .$filepart['extension'];
                    }
                    $dest_file = WINABSPATH . $gallerypath . '/' . $filename;
                    // Check Folder Permissions
                    if (!is_writeable(WINABSPATH.$gallerypath)) {
                      //  $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), WINABSPATH.$gallerypath);
                       // nggGallery::show_error($message);
                        return;
                    }
                    // Save Temporary File
                    if (!@move_uploaded_file($_FILES[$key]['tmp_name'], $dest_file)){
                       // nggGallery::show_error(__('Error, the file could not moved to : ','nggallery').$dest_file);
                        $this->check_safemode(WINABSPATH.$gallerypath);
                        continue;
                    }
                    if (!$this->chmod ($dest_file)) {
                       // nggGallery::show_error(__('Error, the file permissions could not set.','nggallery'));
                        continue;
                    }
                    // Add to Image and Dir List
                    $imageslist[] = $filename;
                    $dirlist[] = $filename;
                }
            }
            if (count($imageslist) > 0) {
    			if ( ! get_option('npu_exclude_select')  ) {
    				$npu_exclude_id = 0;
    			} else {
    				$npu_exclude_id = 1;
    			}
                // Add Images to Database
                $image_ids = $this->add_Images($galleryID, $imageslist);
                $this->arrThumbReturn = array();
                foreach ($image_ids as $pid) {
                    $wpdb->query("UPDATE $wpdb->nggpictures SET exclude = '$npu_exclude_id' WHERE pid = '$pid'");
                    $this->arrThumbReturn[] = $this->create_thumbnail($pid);
                }
                $this->arrImageIds = array();
                $this->arrImageIds = $image_ids;
                $this->arrImageNames =array();
                $this->arrImageNames = $imageslist;
                $this->strGalleryPath = $gallerypath;
            }
            return;
        } // End Function
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic