How to delete one uploaded temp file but keep others from the same form?
Jamroom Developers
Hi Michael
I use that in the function, I probably should have posted the whole thing to start with:
function ujPano_form_validate_exit_listener($_data, $_user, $_conf, $_args, $event)
{
if ($_data['module'] == 'ujPano') {// && isset($_data['pano_equirect_image'])
$_fl = jrCore_get_uploaded_media_files('ujPano','pano_equirect_image');
if ($_fl && is_array($_fl) && isset($_fl[0])) {
foreach($_fl as $_img) {
// check it is 2:1
$_tmp = getimagesize($_img);
$w = (int) $_tmp[0];
$h = (int) $_tmp[1];
if ($w / $h !== 2) {
// it isn't an equirectangular image
global $_post;
jrCore_delete_upload_temp_directory($_post['upload_token']);
//unlink($_img);
jrCore_set_form_notice('notice', "Invalid Equirectangular Image");
jrCore_form_field_hilight('pano_equirect_image');
jrCore_form_result();
} else {
}
}
}
}
return $_data;
}
I've tried deleting the file using unlink($_img) (commented out above) but that results in a continuing failed form validation even when the replacement image passes the equirectangular test. I can't see a way around it.