get_allowed_mime_types
This commit is contained in:
parent
28dbaa63e7
commit
08691415eb
|
@ -674,25 +674,22 @@ function woocommerce_download_product() {
|
||||||
// Download the file
|
// Download the file
|
||||||
$file_extension = strtolower(substr(strrchr($file_path,"."),1));
|
$file_extension = strtolower(substr(strrchr($file_path,"."),1));
|
||||||
|
|
||||||
switch ($file_extension) :
|
$ctype = "application/force-download";
|
||||||
case "pdf": $ctype="application/pdf"; break;
|
|
||||||
case "exe": $ctype="application/octet-stream"; break;
|
foreach (get_allowed_mime_types() as $mime => $type) :
|
||||||
case "zip": $ctype="application/zip"; break;
|
$mimes = explode('|', $mime);
|
||||||
case "doc": $ctype="application/msword"; break;
|
if (in_array($file_extension, $mimes)) :
|
||||||
case "xls": $ctype="application/vnd.ms-excel"; break;
|
$ctype = $type;
|
||||||
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
|
break;
|
||||||
case "gif": $ctype="image/gif"; break;
|
endif;
|
||||||
case "png": $ctype="image/png"; break;
|
endforeach;
|
||||||
case "jpe":
|
|
||||||
case "jpeg":
|
|
||||||
case "jpg": $ctype="image/jpg"; break;
|
|
||||||
case "mp3": $ctype="audio/mpeg"; break;
|
|
||||||
default: $ctype="application/force-download";
|
|
||||||
endswitch;
|
|
||||||
|
|
||||||
if ($file_download_method=='xsendfile') :
|
if ($file_download_method=='xsendfile') :
|
||||||
|
|
||||||
$file_path = trim(str_replace(getcwd(), '', $file_path), '/'); // Path fix - kudos to Jason Judge
|
if (getcwd()) :
|
||||||
|
// Path fix - kudos to Jason Judge
|
||||||
|
$file_path = trim(preg_replace( '`^' . getcwd() . '`' , '', $file_path ), '/');
|
||||||
|
endif;
|
||||||
|
|
||||||
header("Content-Disposition: attachment; filename=\"".basename($file_path)."\";");
|
header("Content-Disposition: attachment; filename=\"".basename($file_path)."\";");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue