Created
April 9, 2014 13:25
-
-
Save PrestaEdit/10270131 to your computer and use it in GitHub Desktop.
PrestaShop | Image upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$field_name = 'block_img'; | |
$temp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS'); | |
$salt = sha1(microtime()); | |
$type = strtolower(substr(strrchr($_FILES[$field_name]['name'], '.'), 1)); | |
if ($error = ImageManager::validateUpload($_FILES[$field_name])) | |
$this->_html .= $this->displayError($error); | |
elseif (!$temp_name || !move_uploaded_file($_FILES[$field_name]['tmp_name'], $temp_name)) | |
$this->_html .= $this->displayError($this->l('An error occurred during the image upload')); | |
elseif (!ImageManager::resize($temp_name, dirname(__FILE__).'/img/'.$salt.'.'.$type)) | |
$this->_html .= $this->displayError($this->l('An error occurred during the image upload.')); | |
if (isset($temp_name)) | |
@unlink($temp_name); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment