mirceabondar Posted January 14, 2013 Share Posted January 14, 2013 Am modificat in productcontroller.php astfel incat sa pot uploada fisiere pdf, psd, cdr..etc. Am scos din cod conditiile: daca este poza, daca a fost redimensionata si daca poza mica exista. Am ramas cu functia asta: public function pictureUpload(Product $product, Cart $cart) { if (!$fieldIds = $this->product->getCustomizationFieldIds()) return false; $authorizedFileFields = array(); foreach ($fieldIds as $fieldId) if ($fieldId['type'] == _CUSTOMIZE_FILE_) $authorizedFileFields[(int)($fieldId['id_customization_field'])] = 'file'.(int)($fieldId['id_customization_field']); $indexes = array_flip($authorizedFileFields); foreach ($_FILES as $fieldName => $file) if (in_array($fieldName, $authorizedFileFields) && isset($file['tmp_name']) && !empty($file['tmp_name'])) { $fileName = time().'_'.$file['name']; if ($error = checkImage($file, (int)(Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE')))) $this->errors[] = $error; $fisier = _PS_UPLOAD_DIR_.$fileName; if (file_exists($fisier)) $mesaj = ""; $mesaj = 'Fisierul a fost incarcat cu succes'; if ($error OR (!$tmpName = $file['name'] OR !move_uploaded_file($file['tmp_name'], $tmpName))) return false; /* Original file */ elseif (!copy($tmpName, _PS_UPLOAD_DIR_.$fileName)) $this->errors[] = Tools::displayError('An error occurred during the image upload.'); /* A smaller one */ else $cart->addPictureToProduct((int)($this->product->id), $indexes[$fieldName], $fileName); unlink($tmpName); Imi uploadeaza fisierele care le vreau numai ca atunci cand adaug in cos si fisierul si produsul in cos, nu mai pot sa sterg din cos decat fisierul..nu si produsul. Ca sa sterg produsul trebuie sa inchid browserul si sai dau cu ccleaner. Eu m-am uitat la $cart->addPictureToProduct((int)($this->product->id), $indexes[$fieldName], $fileName); . Daca sterg codul asta pot sa sterg produsul dar nu imi mai apare fisierul nici in cos nici in panoul de admin. Aveti vreo idee cum as putea adauga in cos decat numele fisierului? (sa pot apoi sa stiu ce a incarcat fiecare client) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now