function _plupload_fix_temporary_filename in Plupload integration 8
Same name and namespace in other branches
- 7.2 plupload.module \_plupload_fix_temporary_filename()
- 7 plupload.module \_plupload_fix_temporary_filename()
- 2.0.x plupload.module \_plupload_fix_temporary_filename()
Fix the temporary filename provided by the plupload library.
Newer versions of the plupload JavaScript library upload temporary files with names that contain the intended final prefix of the uploaded file (e.g., ".jpg" or ".png"). Older versions of the plupload library always use ".tmp" as the temporary file extension.
We prefer the latter behavior, since although the plupload temporary directory where these files live is always expected to be private (and we protect it via .htaccess; see plupload_handle_uploads()), in case it ever isn't we don't want people to be able to upload files with an arbitrary extension into that directory.
This function therefore fixes the plupload temporary filenames so that they will always use a ".tmp" extension.
Parameters
string $filename: The original temporary filename provided by the plupload library.
Return value
string The corrected temporary filename, with a ".tmp" extension replacing the original one.
2 calls to _plupload_fix_temporary_filename()
- PlUploadFile::valueCallback in src/
Element/ PlUploadFile.php - UploadController::getFilename in src/
UploadController.php - Reads, checks and return filename of a file being uploaded.
File
- ./
plupload.module, line 50 - Implementation of plupload.module.
Code
function _plupload_fix_temporary_filename($filename) {
$pos = strpos($filename, '.');
if ($pos !== FALSE) {
$filename = substr_replace($filename, '.tmp', $pos);
}
return $filename;
}