Search the Community
Showing results for tags 'file upload'.
-
Hello, continuation from my previous topic, I'm now stuck on using the Symphony framework to get my custom file uploaded on the server. Using a module, I'm using the formBuilder to create the file input on category page. I'm not quite sure how to proceed from here though. I tried to follow this (https://symfony.com/doc/3.4/controller/upload_file.html) Symfony guide, but couldn't quite apply it to the Prestashop system. I think I should be using the UploadedFile component in my module to handle this, but I've no experience with Symfony and I'm not sure how to properly implement it into my module. Below is my module file, any help would be greatly appreciated <?php if (!defined('_PS_VERSION_')) { exit; } use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Validator\Constraints\File; class CustomCategoryFields extends Module { public function __construct() { $this->name = 'customcategoryfields'; $this->tab = 'administration'; $this->version = '1.0.0'; $this->author = 'RV'; $this->need_instance = 0; $this->ps_versions_compliancy = [ 'min' => '1.7', 'max' => _PS_VERSION_ ]; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Custom Admin Category Fields'); $this->description = $this->l('Adds custom fields to admin category page'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('customcategoryfields')) { $this->warning = $this->l('No name provided'); } } public function install() { return parent::install() && $this->_installSql() && $this->registerHook('actionCategoryFormBuilderModifier') && $this->registerHook('actionAfterCreateCategoryFormHandler') && $this->registerHook('actionAfterUpdateCategoryFormHandler'); } public function uninstall() { if (!parent::uninstall() || !$this->_unInstallSql() || !Configuration::deleteByName('customcategoryfields') ) { return false; } return true; } protected function _installSql() { $sqlInstallLang = 'CREATE TABLE '._DB_PREFIX_.'category_custom_fields ( id_category int(10) NULL, image varchar(255) NULL, img_placement int(10) NULL, img_name varchar(32) NULL, price_impact decimal(20,6) NULL)'; $returnSqlLang = Db::getInstance()->execute($sqlInstallLang); return $returnSqlLang; } protected function _unInstallSql() { $sqlInstallLang = 'DROP TABLE '._DB_PREFIX_.'category_custom_fields'; $returnSqlLang = Db::getInstance()->execute($sqlInstallLang); return $returnSqlLang; } public function hookActionCategoryFormBuilderModifier($params) { $formBuilder = $params['form_builder']; $formBuilder->add('image', FileType::class, [ 'label' => $this->getTranslator()->trans('Image', [], 'Modules.customcategoryfields'), 'required' => false, 'mapped' => false, 'constraints' => [ new File([ 'mimeTypes' => [ 'image/png', ], 'mimeTypesMessage' => 'Obrázek musí být ve formátu PNG', ]) ] ]); $formBuilder->add('img_name', TextType::class, [ 'label' => $this->getTranslator()->trans('Image name', [], 'Modules.customcategoryfields'), 'required' => false, 'data' => $this->getImgName($params['id']) ]); $formBuilder->add('img_placement', NumberType::class, [ 'label' => $this->getTranslator()->trans('Image placement', [], 'Modules.customcategoryfields'), 'required' => false, 'data' => $this->getImgPlacement($params['id']) ]); $formBuilder->add('price_impact', TextType::class, [ 'label' => $this->getTranslator()->trans('Price impact', [], 'Modules.customcategoryfields'), 'required' => false, 'data' => $this->getPriceImpact($params['id']) ]); $formBuilder->setData($params['data']); } public function hookActionAfterCreateCategoryFormHandler($params) { $this->updateCategoryFields($params); } public function hookActionAfterUpdateCategoryFormHandler($params) { $this->updateCategoryFields($params); } public function updateCategoryFields($params) { file_put_contents('../modules/customcategoryfields/test_log.txt', var_dump($_FILES)); $idGet = 'SELECT id_category FROM '._DB_PREFIX_.'category_custom_fields WHERE id_category = '.$params['id']; if (Db::getInstance()->getValue($idGet)) { $sql = 'UPDATE '._DB_PREFIX_.'category_custom_fields SET img_placement = '.$params['form_data']['img_placement'].', img_name = "'.$params['form_data']['img_name'].'", price_impact = '.$params['form_data']['price_impact'].' WHERE id_category = '.$params['id']; } else { $sql = 'INSERT INTO '._DB_PREFIX_.'category_custom_fields (id_category,img_placement,img_name,price_impact) VALUES ('.$params['id'].', '.$params['form_data']['img_placement'].', "'.$params['form_data']['img_name'].'", '.$params['form_data']['price_impact'].')'; } Db::getInstance()->execute($sql); } public function getImgName($id_category) { $sqlName = 'SELECT img_name FROM '._DB_PREFIX_.'category_custom_fields WHERE id_category = '.$id_category; return Db::getInstance()->getValue($sqlName) ? Db::getInstance()->getValue($sqlName) : ''; } public function getImgPlacement($id_category) { $sqlPlace = 'SELECT img_placement FROM '._DB_PREFIX_.'category_custom_fields WHERE id_category = '.$id_category; return Db::getInstance()->getValue($sqlPlace) ? (int)Db::getInstance()->getValue($sqlPlace) : 1; } public function getPriceImpact($id_category) { $sqlPrice = 'SELECT price_impact FROM '._DB_PREFIX_.'category_custom_fields WHERE id_category = '.$id_category; return Db::getInstance()->getValue($sqlPrice) ? (float)Db::getInstance()->getValue($sqlPrice) : 0; } }
-
file upload PrestaShop cant upload file
Jegadeesh posted a topic in Configuring and using PrestaShop
I cant upload files(add files) in prestashop backoffice like add category images, image slider and theme add file images. I dont know whats the problem? can any one tell me possible suggestions to check? -
Greetings fellow PS'ers Im working on my first prestashop and i still need to solve one thing. In my case it is bad usability. Some of my products is customizable where the user have to upload one or more images. At the moment one have to add a certain input of files fields, eg. 5 fields for 5 images. My question is: Is there a way to modify the cutsomifization block in products.tpl to ONE FILE UPLOADER can handle multiple images? An array ofc. In that case, what changes shall i make to what files? Sorry for my bad formulations.
- 4 replies
-
- Product Cutomization
- File Upload
-
(and 3 more)
Tagged with:
-
Hi, is there a way to force new customers to upload company documents during registration? I know it is possible with order but I want to verify my customers before giving them access to my site. Thanks in advance.
-
Hi everyone For my products I have Product customization. Catalog , Products ,Product customization, I add to product. Now when I click on product on the bottom it has where you can upload the file. When I upload a jpg, png, etc. The picture does not show ? Their is a X. Now when I complete the order it shows in the back end. How can I get the pic to show when they select the file. Thanks So Much, Troy
- 18 replies
-
- file size
- pictures uploaded by customer
- (and 5 more)
-
Hi community. I'm wondering why I get the result of the attached image with the following code: $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Import combinations'), 'image' => '../img/admin/cog.gif' ), 'input' => array( array( 'type' => 'file', 'name' => 'my-name', 'multiple' => true, 'label' => $this->l('Choose combinations file'), 'desc' => $this->l('Terms display on the top of the form.'), 'lang' => true, 'id' => 'my-name' ) ), 'submit' => array( 'title' => $this->l('Import'), 'class' => 'button' ) ); $helper = new HelperForm(); $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; $helper->languages = Language::getLanguages(); $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; $helper->title = $this->displayName; $helper->show_toolbar = true; $helper->toolbar_scroll = true; $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'), ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // $helper->fields_value['BETTERPRICE_EMAIL'] = Configuration::get('BETTERPRICE_EMAIL'); return $helper->generateForm($fields_form);
- 6 replies
-
- file input type
- file upload
-
(and 1 more)
Tagged with:
-
For a new shop I am looking for two solutions. Question 1: Creating Product Attributes depending on the above attribute. I want to offer photo edits per printing method in different formats. Example: print on canvas can be ordered with 20x30 and 30x40 and print can be ordered on 40x40 and 40x50 on wood. I cannot realize this as I get the product combinations to see all the possibilities. So I want to make some formats invisible to canvas or wood. Question 2: File upload position there is the ability to upload a file to a product, but the uploadfield is below more information, upload information and therefore not directly into the field of view. I can make the upload required, which is useful, but the error message does not state on what is missing or what field is required. I prefer to put the upload field between the attributes, but I do not see this option. I use prestashop 1.6 regards, Almo Sorry for my bad english, I used google translate
-
- productattribute
- dependencies
-
(and 1 more)
Tagged with:
-
Voor een nieuwe webshop ben ik op zoek naar twee oplossingen. Vraag 1: Productattributen afhankelijk maken van bovenstaande attribuut. Ik wil fotobewerkingen per afdrukmethode aanbieden in verschillende formaten. voorbeeld: afdruk op canvas kan besteld worden met 20x30 en 30x40 en afdruk op hout kan besteld worden op 40x40 en 40x50. Ik kan dit nu niet realiseren omdat ik bij de productcombinaties alle mogelijkheden te zien krijg. Ik wil dus enkele formaten onzichtbaar maken voor canvas of hout. Vraag 2: Foto upload hoger plaatsen er is de mogelijkheid om een foto te uploaden bij een product maar het veld upload is te vinden onder meer informatie en dus niet direct in het zichtveld. Ik kan de upload wel verplicht maken, wat handig is, maar de foutmelding geeft niet duidelijk aan wat er ontbreekt of welk veld niet ingevuld is. Het liefst zet ik het upload veld tussen de attributen maar ik zie niet direct deze mogelijkheid. Ik gebruik prestashop 1.6 Groet, Almo
-
- file upload
- foto upload
-
(and 1 more)
Tagged with:
-
Hi, Something that I noticed immediately after playing around with Prestashop is that users cannot upload non-image formats like zip, rar, doc, and pdf. Prestashop limits file formats to image formats like JPG, PNG, GIF etc. Why is this? I'm trying to customize a print services website where customers upload artwork and this restriction is very annoying considering that other carts like Opencart allows any file format to be uploaded. Is there any way around this? Has the latest version fixed this problem? Any advice will be much appreciated. Thanks Viraj
-
Ok. So I come back again looking for help from dear forum members. I know that there is a way to allow customers to upload image files, gif, jpg and png from front-end through customized product option in prestashop 1.5.2. But why uploading other file extensions is left over. It should have been left to the site administrator to control upload file extension. Security may be a concern but site administrator is best person to judge that. OK. So i wanna achieve that in my second website that I am building using prestashop. I am building a printing website where customer can upload/attach pdf, coreldraw, photoshop and autocad files in every product that they order. Can somebody guide me precisely where to do change in code so that a customer can upload/attach any kind of file to customized product apart from just plain images. I am short on finance currently so can't afford to have any paid module to achieve that.
- 3 replies
-
- 2
-
-
- file upload
- upload pdf
-
(and 3 more)
Tagged with:
-
Recently i tried to upload some product pic in my store but couldn't upload the image.The store shows image uploaded successfully but image is not there and additionally while uploading modules it is showing file not selected . While parsing error following error is detected in modules only Warning: session_start() [function.session-start]: open(/var/chroot/home/content/a/g/s/agslazimpat/tmp/sess_vnpi9u7794ho6gcpo9a008rj85, O_RDWR) failed: No such file or directory (2) in /home/content/a/g/s/agslazimpat/html/kathmanduclothing/ktmprestashop/classes/Module.php(551) : eval()'d code on line 36
-
Recently i tried to upload some product pic in my store but couldn't upload the image.The store shows image uploaded successfully but image is not there and additionally while uploading modules it is showing file not selected . While parsing error following error is detected in modules only Warning: session_start() [function.session-start]: open(/var/chroot/home/content/a/g/s/agslazimpat/tmp/sess_vnpi9u7794ho6gcpo9a008rj85, O_RDWR) failed: No such file or directory (2) in /home/content/a/g/s/agslazimpat/html/kathmanduclothing/ktmprestashop/classes/Module.php(551) : eval()'d code on line 36
-
Hi I hope someone can point me in the right direction with this. I have just updated my store to version 1.4.7 and am using the default theme. My store sells personalised products and I use the customization feature for customers to upload image files and text. Since I updated I have the following problems: Image files are not saved to the back office. On saving the customisation a 'success' message is displayed and the customer can check out however the image is not available to view. Entries into text boxes are saved in Internet Explorer however, if an entry is 'required' then Firefox and Chrome appears to save the text however when you try to check out there is an error message that says "Please fill in all required fields and then save". The text is saved correctly in all browsers if the fields are not 'required'. I have been using these features in Prestashop since version 1.2 and have not had any errors before - could someone please let me know if this is a configuration problem on my part or an error. The issues can be seen at: www.yourphotojigsaw.co.uk
- 8 replies
-
- 1
-
-
- customisation
- customization
-
(and 1 more)
Tagged with:
-
Hi guys, I'm trying to move Product Customization (file upload to be specific) from product.tpl to order-carrier.tpl in order steps. Simply I want my customers to upload their pics in last stages of order. When I copy the proper code for product customization and put it in a new place it doesn't work because condition: {if $product->customizable} [...] } is "inactive" there. Could somebody help me or give me a hint or is it a more complex situation and it can't be solved that easily ? cheers!