1
fatman
XoopsMediaUploader saving file with slashes
  • 2004/1/25 3:16

  • fatman

  • Friend of XOOPS

  • Posts: 176

  • Since: 2003/12/13


Hi I making use of a the /class/uploader.php file to assist with an image upload for a module I'm working on.

If I upload a file which has a single quote such as
image'name.jpg the file gets saved as image\'name.jpg

obviously the uploader is adding slashes for database insertion into the database. However this creates a lot of issues when trying to delete the file or change its properties via FTP or another such method. My FTP sees the file as having a prohibitted name.

Is their a reason why the file is saved with slashes? Couldn't these be added purly for storage in the database.

I'm guessing that this bit of code found in uploader.php lets me suggest a target file name. If this is correct, could someone explain to me how to engage it?
function setTargetFileName($value){
   
$this->targetFileName strval(trim($value));
}


Here is a snippet of my own code in case it helps.
// Include the XOOPS uploader class
  
include_once XOOPS_ROOT_PATH.'/class/uploader.php';

  
// create an instance of the uploader and provide settings
  
$uploader = new XoopsMediaUploader($org_path$allowed_mimetypes$maxfilesize$maxfilewidth$maxfileheight);

  if (
$uploader->fetchMedia($form_field_name)) 
  {
    if (!
$uploader->upload()) 
    {
       echo 
$uploader->getErrors();
    } else {

$uploader->getSavedDestination();
        
        
// Capture info about the file save
        
$saved_file $uploader->getSavedFileName();
        
$full_path $uploader->getSavedDestination();
        
        print 
$saved_file;
    }

  } else {
    echo 
$uploader->getErrors();
    return;
  }

2
fatman
Re: XoopsMediaUploader saving file with slashes
  • 2004/1/25 3:47

  • fatman

  • Friend of XOOPS

  • Posts: 176

  • Since: 2003/12/13


I provided a work around by just renaming the file to a random number. And then called the targetFileName. here is my modified code below in case anyone is interested.

$file $_FILES[$form_field_name]['name'];
$n explode('.'$file);
$target_file $time().".".$n[1];

  
// Include the XOOPS uploader class
  
include_once XOOPS_ROOT_PATH.'/class/uploader.php';

  
// create an instance of the uploader and provide settings
  
$uploader = new XoopsMediaUploader($org_path$allowed_mimetypes$maxfilesize$maxfilewidth$maxfileheight);

  
$uploader->setTargetFileName($target_file);

  if (
$uploader->fetchMedia($form_field_name)) 
  {
    if (!
$uploader->upload()) .... continued

3
onokazu
Re: XoopsMediaUploader saving file with slashes
  • 2004/1/25 7:04

  • onokazu

  • XOOPS Founder

  • Posts: 617

  • Since: 2001/12/13


I think this is because of the magic quotes. I have fixed this now on CVS, and will be included in the next package.

Login

Who's Online

221 user(s) are online (100 user(s) are browsing Support Forums)


Members: 0


Guests: 221


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits