Welcome Guest, Not a member yet? Register   Sign In
Problem with File Uploading Class
#1

[eluser]Larry Wakeman[/eluser]
I am trying to upload a file with multiple periods in the name, i.e. header.1.0.0.zip. When the file is uploaded, it is named header.1_.0_.0_.zip, note the extra underbars. Makes it difficult to find the file.

Code:
FILES Array
(
    [userfile] => Array
        (
            [name] => header.1.0.0.zip
            [type] => application/zip
            [tmp_name] => C:\Program Files\xampp\tmp\phpA5D.tmp
            [error] => 0
            [size] => 341
        )

)
Config Array
(
    [upload_path] => C:/Users/Larry/CICmS/www/temp/2b1c90a1aa3cbe60aab4cf93b4f711de/
    [allowed_types] => zip
    [overwrite] => 1
    [remove_spaces] => false
)

Is their any magic incantation I can make to make the file name not get translated?
#2

[eluser]Larry Wakeman[/eluser]
I found where the problem is occurring. In the function _prep_filename in upload.php is adding the underbars to the filename. It's comment is:

* Prevents possible script execution from Apache's handling of files multiple extensions
* http://httpd.apache.org/docs/1.3/mod/mod...ultipleext

The apache page says:

Files with Multiple Extensions

Files can have more than one extension, and the order of the extensions is normally irrelevant. For example, if the file welcome.html.fr maps onto content type text/html and language French then the file welcome.fr.html will map onto exactly the same information. If more than one extension is given which maps onto the same type of meta-information, then the one to the right will be used, except for languages and content encodings. For example, if .gif maps to the MIME-type image/gif and .html maps to the MIME-type text/html, then the file welcome.gif.html will be associated with the MIME-type text/html.

Languages and content encodings are treated accumulative, because one can assign more than one language or encoding to a particular resource. For example, the file welcome.html.en.de will be delivered with Content-Language: en, de and Content-Type: text/html.

Care should be taken when a file with multiple extensions gets associated with both a MIME-type and a handler. This will usually result in the request being by the module associated with the handler. For example, if the .imap extension is mapped to the handler "imap-file" (from mod_imap) and the .html extension is mapped to the MIME-type "text/html", then the file world.imap.html will be associated with both the "imap-file" handler and "text/html" MIME-type. When it is processed, the "imap-file" handler will be used, and so it will be treated as a mod_imap imagemap file.

I don't see the issue. Some parameter in the config file should allow me to turn this off.
#3

[eluser]Larry Wakeman[/eluser]
I created a MU_Upload class and overrode _prep_filename as follows:

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* File Uploading Class
*
* @package        CodeIgniter
* @subpackage    Libraries
* @category    Uploads
* @author        ExpressionEngine Dev Team
* @link        http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html
*/
class MY_Upload extends CI_Upload {

    /**
     * Prep Filename
     *
     * The CI basic class modifies the file name of files with mutiple extensions, this is not what is needed
     *
     * @access    private
     * @param    string
     * @return    string
     */
    function _prep_filename($filename)
    {
        return $filename;
    }

    // --------------------------------------------------------------------

}
// END Upload Class

/* End of file Upload.php */
/* Location: ./system/applocation/libraries/MY_Upload.php */




Theme © iAndrew 2016 - Forum software by © MyBB