php - WooCommerce - Trying to Make Uploaded Files links clickable in Backend -
i using woo-commerce plugin wordpress website. in using calculators receiving orders. whenever user upload file getting path regarding file in backend can see in link http://promo.inkgility.com/wp-content/uploads/2015/05/screenshot_2.png
upload file: path shows product
trying make link clickable not able find correct code.
please put code in file , downloaded. create new file download.php , path on below link.
<a href="download.php?file=path/<?php echo row['file_name']?>">download</a> using below function image start download.
<?php function download_file( $fullpath ){ // must fresh start if( headers_sent() ) die('headers sent'); // required browsers if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'off'); // file exists? if( file_exists($fullpath) ){ // parse info / extension $fsize = filesize($fullpath); $path_parts = pathinfo($fullpath); $ext = strtolower($path_parts["extension"]); // determine content type switch ($ext) { case "pdf": $ctype="application/pdf"; break; case "exe": $ctype="application/octet-stream"; break; case "zip": $ctype="application/zip"; break; case "doc": $ctype="application/msword"; break; case "xls": $ctype="application/vnd.ms-excel"; break; case "ppt": $ctype="application/vnd.ms-powerpoint"; break; case "gif": $ctype="image/gif"; break; case "png": $ctype="image/png"; break; case "jpeg": case "jpg": $ctype="image/jpg"; break; default: $ctype="application/force-download"; } header("pragma: public"); // required header("expires: 0"); header("cache-control: must-revalidate, post-check=0, pre-check=0"); header("cache-control: private",false); // required browsers header("content-type: $ctype"); header("content-disposition: attachment; filename=\"".basename($fullpath)."\";" ); header("content-transfer-encoding: binary"); header("content-length: ".$fsize); ob_clean(); flush(); readfile( $fullpath ); } else die('file not found'); } ?> in can download way.
<a href="/images/myw3schoolsimage.jpg" download> <img border="0" src="/images/myw3schoolsimage.jpg" alt="w3schools" width="104" height="142"> </a> let me know once code working.
Comments
Post a Comment