Theresa Arzadon-Labajo

Media Manager - White space and case

Posted by Theresa Arzadon-Labajo (tarzadon) on Apr 19 2007
Tech Stuff >> Joomla
The Media Manager in Joomla automatically changes filenames to lowercase.

It also allows a user to upload a filename with spaces. However, after the file is uploaded, the user cannot delete it.

I edited the code so that Joomla will preserve case as well as replace whitespace with an underscore.

The file is administrator/components/com_media/admin.media.php

This is the original code: (Line number 205)

if (!move_uploaded_file($file['tmp_name'], $dest_dir.strtolower($file['name']))){
mosRedirect( "index2.php?option=com_media&listdir=".$_POST['dirPath'], "Upload FAILED" );
} else {
mosChmod($dest_dir.strtolower($file['name']));
mosRedirect( "index2.php?option=com_media&listdir=".$_POST['dirPath'], "Upload complete" );
}

Replace it with:

// Strip white space from file name
$new_file_name = $file['name'];
$new_file_name = preg_replace('/\s+/', '_', $new_file_name);

if (!move_uploaded_file($file['tmp_name'], $dest_dir.($new_file_name))){
mosRedirect( "index2.php?option=com_media&listdir=".$_POST['dirPath'], "Upload FAILED" );
} else {
mosChmod($dest_dir.($new_file_name));
mosRedirect( "index2.php?option=com_media&listdir=".$_POST['dirPath'], "Upload complete" );
}

 

Last changed: Apr 19 2007 at 3:16 PM

Back

Comments

ovhinject By Guest on Oct 21 2020 at 8:26 AM
trick google meet
wonderful indonesia

Add Comment