pskeeda 6 Posted May 1, 2014 I am using PS 1.6, i want to enable PDF file upload in Product Customization. Currently i am able to upload only jpg, gif and png files. Please know, how to enable the same. Share this post Link to post Share on other sites
Esoterick 0 Posted May 9, 2014 (edited) To allow PDF upload, I override the ProductController::pictureUpload method in override/controllers/front. In the following class: has been tested with PS 1.6.0.5 and 1.6.0.6, images are still handled by PrestaShop core, files are uploaded in uploads/customizations/{cart_id}. You can remove this feature by editing lines 3, 33 and 36, files that are not handled by PrestaShop core are prefixed with a "P". some modules are editing the admin/displayImage.php file, but as I couldn't find any usage, I didn't. If you want to do this, you'll have to test the first letter of the file to send correct mime-type to the browser. In your theme, in the product.tpl file, you can detect if the file is an image or a PDF with the folliwng code. if isset($pictures.$key)} <div class="customizationUploadBrowse"> {if substr(basename($pictures.$key), 0, 1) == 'P'} <a href="{$pic_dir}{$pictures.$key}" target="_blank">{l s='View the file'}</a> {else} <img src="{$pic_dir}{$pictures.$key}_small" alt="" /> {/if} <a href="{$link->getProductDeletePictureLink($product, $field.id_customization_field)|escape:'html':'UTF-8'}" title="{l s='Delete'}" > <img src="{$img_dir}icon/delete.gif" alt="{l s='Delete'}" class="customization_delete_icon" width="11" height="13" /> </a> </div> {/if} I hope this will help you. Regards. ProductController.php Edited May 9, 2014 by Esoterick (see edit history) Share this post Link to post Share on other sites
pskeeda 6 Posted September 3, 2014 Dear Esoterick,Thanks for your reply. Since i am not a technical person, can you please elaborate that which files i need to edit to enable pdf upload.Your reply will be highly appreciated. Share this post Link to post Share on other sites
id-print 0 Posted December 18, 2014 Hi everybody, I tried the Esoteick method but it doesn't work. Any help ? Thanks Share this post Link to post Share on other sites
onofredelariva 0 Posted January 4, 2016 Hola a todos yo tengo prestashop 1.6.1.0 y este módulo funsiona muy bien para subir PDF https://www.prestashop.com/forums/topic/456742-free-module-file-upload-let-customers-upload-other-files-besides-images/ Saludos. Share this post Link to post Share on other sites
fatum 2 Posted January 5, 2016 (edited) Esoterick fix works very well! (PS 1.6.0.5)- Download his ProductController.php and upload it in /override/controllers/front/; - Clear Prestashop cache; - Now you have to fix the file preview in frontend, in product.tpl you can use the code portion Esoterick suggest: {if isset($pictures.$key)} <div class="customizationUploadBrowse"> {if substr(basename($pictures.$key), 0, 1) == 'P'} <a href="{$pic_dir}{$pictures.$key}" target="_blank">{l s='View the file'}</a> {else} <img src="{$pic_dir}{$pictures.$key}_small" alt="" /> {/if} <a href="{$link->getProductDeletePictureLink($product, $field.id_customization_field)|escape:'html':'UTF-8'}" title="{l s='Delete'}" > <img src="{$img_dir}icon/delete.gif" alt="{l s='Delete'}" class="customization_delete_icon" width="11" height="13" /> </a> </div> {/if} - Open "order-payment.tpl", "order-detail.tpl", "order-return.tpl" and search for "customizationUploaded", comment the div and paste this code above it: {foreach from=$datas item='data'} {if substr(basename($data.value), 0, 1) == 'P'} <a href="{$pic_dir}{$data.value}" target="_blank">Open attached file</a> {else} <img src="{$pic_dir}{$data.value}_small" alt="" /> {/if} <a href="{$link->getProductDeletePictureLink($product, $field.id_customization_field)|escape:'html':'UTF-8'}" title="{l s='Delete'}" > <img src="{$img_dir}icon/delete.gif" alt="{l s='Delete'}" class="customization_delete_icon" width="11" height="13" /> </a> {/foreach} - Now open "shopping-cart.tpl", again search for search for "customizationUploaded" comment the div and paste this code above it: {foreach $custom_data as $picture} {if substr(basename($picture.value), 0, 1) == 'P'} <a href="{$pic_dir}{$picture.value}" target="_blank">Open attached file</a> {else} <img src="{$pic_dir}{$picture.value}_small" alt="" /> {/if} <a href="{$link->getProductDeletePictureLink($product, $field.id_customization_field)|escape:'html':'UTF-8'}" title="{l s='Delete'}" > <img src="{$img_dir}icon/delete.gif" alt="{l s='Delete'}" class="customization_delete_icon" width="11" height="13" /> </a> {/foreach} - Now last step: open "/ps-admin/themes/default/template/controllers/orders/_customized_data.tpl", search for "Product::CUSTOMIZE_FILE", comment the first foreach and paste this code above: {foreach from=$datas item=data} <div class="form-group"> <span class="col-lg-4 control-label"><strong>{if $data['name']}{$data['name']}{else}{l s='Picture #'}{$data@iteration}{/if}</strong></span> <div class="col-lg-8"> {if substr(basename($data.value), 0, 1) == 'P'} <a href="{$pic_dir}{$data.value}" target="_blank">Open attached file</a> {else} <a href="displayImage.php?img={$data['value']}&name={$order->id|intval}-file{$data@iteration}" class="_blank"> <img class="img-thumbnail" src="{$smarty.const._THEME_PROD_PIC_DIR_}{$data['value']}_small" alt=""/> </a> {/if} </div> </div> {/foreach} That's it ;-) ProductController.php Edited September 27, 2016 by fatum (see edit history) Share this post Link to post Share on other sites
Esoterick 0 Posted January 5, 2016 Thanks fatum for taking the time to explain my reply Share this post Link to post Share on other sites
fatum 2 Posted January 5, 2016 (edited) Thanks fatum for taking the time to explain my reply ;-) you save me! thank you! Edited January 5, 2016 by fatum (see edit history) Share this post Link to post Share on other sites
hanny137 0 Posted September 27, 2016 This doesn't appear to be working on 1.6.1.7 Bummer, because I really needed it to! Share this post Link to post Share on other sites