Error displayed Upon Upload – "xxx.jpg is not a valid file".
-
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?
https://www.ads-software.com/extend/plugins/nextgen-public-uploader/
-
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 [https://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 }
- The topic ‘Error displayed Upon Upload – "xxx.jpg is not a valid file".’ is closed to new replies.