Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isset ( $postData ['image_'] ) && $postData ['image_'] ['error'] == 0) {
- $adapter = new Http ();
- $fileName = $postData ['image_'] ['name'];
- $extension = pathinfo ( $fileName, PATHINFO_EXTENSION );
- $name = 'image_' . $id;
- $uploadPath = sprintf ( '/upload/product/%d/%d/', substr ( $id, strlen ( $id ) - 2, 2 ), substr ( $id, strlen ( $id ) - 4, 2 ) );
- if (! is_dir ( APPLICATION_PATH . $uploadPath )) {
- mkdir ( APPLICATION_PATH . $uploadPath, 0755, true );
- }
- $renameOptions ['target'] = APPLICATION_PATH . $uploadPath . $name . '.' . $extension;
- $filters = array ();
- $filters [] = new Rename ( $renameOptions );
- $adapter->setFilters ( $filters );
- if ($adapter->isValid ()) {
- $adapter->receive ();
- }
- $product->image = $uploadPath . $name . '.' . $extension;
- $this->getService ()->getEntityManager ()->persist ( $product );
- $this->getService ()->getEntityManager ()->flush ();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement