Support » Fixing WordPress » Upload ICO

  • Hey all, I seem to be having a problem with my plugin. When I allow a user to upload a favicon it wont upload, it returns the error no image was uploaded, which is wrong, i’m not sure why it wont recognize an icon, any other image will work though.

    function image_validate_setting($plugin_options) {
    	$keys = array_keys($_FILES);
    	$i = 0;
    	foreach ( $_FILES as $image ) {
    		// if a files was upload
    		if ($image['size'] > 0) {
    		// if it is an image
    			if ( preg_match('/(ico|jpg|jpeg|png|gif)$/', $image['type']) ) {
    				$override = array('test_form' => false);
    				// save the file, and store an array, containing its location in $file
    				$file = wp_handle_upload( $image, $override );       $plugin_options[$keys[$i]] = $file['url'];
    			} else {
    				// Not an image.
    				$options = get_option('image_options');
    				$plugin_options[$keys[$i]] = $options[$logo];
    				// Die and let the user know that they made a mistake.
    				echo $image['size'];
    				wp_die('No image was uploaded.');
    			}
    	}
    	// Else, the user didn't upload a file.
    	// Retain the image that's already on file.
    	else {
    		$options = get_option('image_options');
    		$plugin_options[$keys[$i]] = $options[$keys[$i]];
    	}   $i++; 
    
    } return $plugin_options;
    
    }
  • The topic ‘Upload ICO’ is closed to new replies.