uploadify 外掛程式在Google上一切都ok
但是在Firefox上一直報
302錯誤
網上找了一大把資料 模糊的意思是在
Firefox上伺服器端要判斷session的值 因為前端沒有發過來 所以會驗證失敗 導致重新導向 可是具體如何操作的?
針對PHP的具體辦法是什嗎?
求回答相關話題,無關緊要或沒意義的回帖我會踩你,謝謝!
/*以下是用戶端代碼*/ ____________分割線______________/*以下是服務端代碼*/public function uploadify() { $type = $_GET['type']; $targetPath = './uploads/uploadify_file'; $verifyToken = md5('unique_salt' . $_POST['timestamp']); if (!empty($_FILES) && $_POST['token'] == $verifyToken) { $tempFile = $_FILES['Filedata']['tmp_name']; if (!file_exists($targetPath)) { @mkdir($targetPath); chmod($targetPath, 0777); } $file_name = $_FILES['Filedata']['name']; $hz = explode(".",$_FILES['Filedata']['name']); $targetFile = rtrim($targetPath,'/') . '/' . md5(time()).".".$hz[1]; // Validate the file type $fileTypes = array('doc','docx','pdf'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); if (in_array($fileParts['extension'],$fileTypes)) { if(move_uploaded_file($tempFile,$targetFile)){ $file_message = array( 'file_name'=>$file_name, 'file_creat_time'=>time(), 'file_url'=> $targetFile, 'file_type'=>$type ); $res = $this->files_Model->insert($file_message); if (!$res) { echo '檔案'.$file_message['name'].'儲存失敗'; return FALSE; }else{ echo '上傳成功'; return TRUE; } }else{ echo '啊哦!檔案移動失敗了,請檢查檔案路徑'; return FALSE; } } else { echo '檔案類型不匹配哈!'; return FALSE; } } }
回複內容:
uploadify 外掛程式在Google上一切都ok
但是在Firefox上一直報302錯誤
網上找了一大把資料 模糊的意思是在Firefox上伺服器端要判斷session的值 因為前端沒有發過來 所以會驗證失敗 導致重新導向 可是具體如何操作的?
針對PHP的具體辦法是什嗎?
求回答相關話題,無關緊要或沒意義的回帖我會踩你,謝謝!
/*以下是用戶端代碼*/ ____________分割線______________/*以下是服務端代碼*/public function uploadify() { $type = $_GET['type']; $targetPath = './uploads/uploadify_file'; $verifyToken = md5('unique_salt' . $_POST['timestamp']); if (!empty($_FILES) && $_POST['token'] == $verifyToken) { $tempFile = $_FILES['Filedata']['tmp_name']; if (!file_exists($targetPath)) { @mkdir($targetPath); chmod($targetPath, 0777); } $file_name = $_FILES['Filedata']['name']; $hz = explode(".",$_FILES['Filedata']['name']); $targetFile = rtrim($targetPath,'/') . '/' . md5(time()).".".$hz[1]; // Validate the file type $fileTypes = array('doc','docx','pdf'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); if (in_array($fileParts['extension'],$fileTypes)) { if(move_uploaded_file($tempFile,$targetFile)){ $file_message = array( 'file_name'=>$file_name, 'file_creat_time'=>time(), 'file_url'=> $targetFile, 'file_type'=>$type ); $res = $this->files_Model->insert($file_message); if (!$res) { echo '檔案'.$file_message['name'].'儲存失敗'; return FALSE; }else{ echo '上傳成功'; return TRUE; } }else{ echo '啊哦!檔案移動失敗了,請檢查檔案路徑'; return FALSE; } } else { echo '檔案類型不匹配哈!'; return FALSE; } } }
首先,我是JAVA開發,但是這個問題本質跟語言無關
問題是session丟失的問題,那麼你需要在請求的時候帶上JSONID傳過去,就像使用者瀏覽器禁用cookie的url重寫一樣。