How to delete one uploaded temp file but keep others from the same form?
Jamroom Developers
a form, with a multi-upload form field.
submit 10 images, but delete #8 for whatever reason and save the other 9.
I'll setup and see if I can see a way.
/**
* Get media files that have been uploaded from a form
* NOTE: $module is no longer used in this function, but was
* at one time so is left there for backwards compatibility
* @param string $module Module Name to check file for
* @param string $file_name Name of file field in form
* @return mixed
*/
function jrCore_get_uploaded_media_files($module = null, $file_name = null){
global $_post;
if (isset($_post['upload_token']{0})) {
$dir = jrCore_get_upload_temp_directory($_post['upload_token']);
if (is_dir($dir)) {
if (is_null($file_name)) {
$_tmp = glob("{$dir}/*.tmp", GLOB_NOSORT);
}
else {
$_tmp = glob("{$dir}/*_{$file_name}.tmp", GLOB_NOSORT);
}
if ($_tmp && is_array($_tmp) && count($_tmp) > 0) {
foreach ($_tmp as $k => $v) {
$_tmp[$k] = substr($v, 0, strlen($v) - 4);
}
sort($_tmp, SORT_NATURAL);
return $_tmp;
}
}
}
return false;
}