adamchaczka LiteCart Fan Dari Poland Anggota sejak Okt 2023 adamchaczka 7 Agu 2024 15:16 Great addon. This could be the solution to my problem with the color sample of each product. However, I don't see any section with files on the page. Is there anything else I need to do besides uploading the files and a piece of code? Here is link to product with pdf file https://mybudio.eu/en/interior-decorations-c-22/decorative-effects-for-the-wall-c-3/rust-effect-klondike-corten-valpaint-set-p-76 In attachment is proof
tim Founder Dari Sweden Anggota sejak Mei 2013 tim 7 Agu 2024 16:59 Do you run a different template name? If so, you would need to adjust the template part in the mod to match your template.
adamchaczka LiteCart Fan Dari Poland Anggota sejak Okt 2023 adamchaczka 7 Agu 2024 18:33 Now I see. Dodo did a few things for me and changed the template name. I didn't know about it until now Thank you for your help. Now it is working But one more question. I would like the file to immediately open in the same window. How to do it? The files added to products are catalogs with color samples
tim Founder Dari Sweden Anggota sejak Mei 2013 tim 8 Agu 2024 11:25 For the same window remove the attribute target="_blank" from the anchor tag.
adamchaczka LiteCart Fan Dari Poland Anggota sejak Okt 2023 adamchaczka 8 Agu 2024 13:11 It works great with Safari but nothing changes when I use PC and mobile Chrom I thought that in my case it would be great if the file was just displayed without downloading. THIS leads to a change in the code. Could you take a look from an expert and tell me if there will be any problems if I use it? require_once('includes/app_header.inc.php'); try { if (empty($_GET['product_id'])) throw new Exception('Invalid product_id'); if (empty($_GET['file_id'])) throw new Exception('Invalid file_id'); $file_query = database::query( "select * from ". DB_TABLE_PREFIX ."products_files where product_id = ". (int)$_GET['product_id'] ." and id = ". (int)$_GET['file_id'] ." limit 1;" ); if (!$file = database::fetch($file_query)) throw new Exception('Could not find a reference for the given file_id', 400); $src = FS_DIR_STORAGE . 'data/files/' . $file['file']; if (!is_file($src)) { trigger_error('Missing attachment '. $file['file'] . ' for product ' . $file['product_id'], E_USER_WARNING); throw new Exception('Found a reference for the file but it does not exist on the disk', 404); } header('Content-Type: ' . $file['mime']); header('Content-Disposition: inline; filename="' . $file['filename'] .'"'); header('Content-Length: ' . filesize($src)); $fh = fopen($src, 'rb'); while ($buffer = fread($fh, 1024)) echo $buffer; fclose($fh); exit; } catch (Exception $e) { http_response_code($e->getCode()); notices::add('errors', $e->getMessage()); } ?>```
tim Founder Dari Sweden Anggota sejak Mei 2013 tim 8 Agu 2024 23:01 To display without downloading you have to edit the get_file.inc.php script and set the right mime type in the HTTP header for Content-Type and set content disposition to "inline". You asked 😉 If the mime type is not supported by the browser it will fallback to downloading.
adamchaczka LiteCart Fan Dari Poland Anggota sejak Okt 2023 adamchaczka 9 Agu 2024 13:53 Screw it. Better is the enemy of Good - as we say in Poland. I'm leaving it as the creator intended it. Thx for help Tim