public function uploadProjectFilesAction() { $result = array(); $result['success'] = 0; $result['message'] = 'Some error occured! Please try again later!'; if (!empty($_FILES)) { $width = 1024; $height = 1024; $fileName = ''; $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = APPLICATION_PUBLIC_PATH . '/media/temps'; $info = pathinfo($_FILES['Filedata']['name']); $info['extension'] = strtolower($info['extension']); $hashkey = "_" . date('d-m-Y'); //$hashkey = md5(sha1(uniqid(mt_rand(10000, 90000).microtime(true), true))); //$hashkey = "_".substr($hashkey, 0, 6); $shorteFilename = substr($info['filename'], 0, 30); $fileName = $shorteFilename . $hashkey . "." . $info['extension']; //new name $targetFile = rtrim($targetPath, '/') . '/' . $fileName; // new path // Validate the file type //@move_uploaded_file($tempFile,$targetFile); //@chmod($targetFile, 0777); //save in Admin Temp Files $resize = new Needs_Resize($tempFile); $resize->resizeTo(1024, 1024); $resize->saveImage($targetFile); $tempFiles = new Default_Model_TempFiles(); $tempFiles->setUserId(Zend_Registry::get('user')->getId()); $tempFiles->setFileName($fileName); $tempFiles->setType('project_files'); $tempFiles->setFileSize(Needs_Tools::findsize($targetFile)); $tempFiles->setFileType($info['extension']); $tempId = $tempFiles->save(); if ($tempId) { $result['success'] = 1; $result['fileId'] = $tempId; } } echo Zend_Json_Encoder::encode($result); }