這裏是我用來上傳文件並將其解壓縮到目錄中的代碼。 但問題是,對於大於5MB的文件,它似乎很慢。 我認爲它不必與網絡,因爲它在本地計算機。 我是否需要編輯php.ini文件或apache或任何其他workarround中的任何參數?在PHP中緩慢上傳joomla controler
$target_path = "../somepath/";
$target_path .= JRequest::getVar('uploadedDirectory')."/";
$target_Main_path= JRequest::getVar('uploadedDirectory')."/";
$folderName = $_FILES['uploadedfile']['name'];
$target_path = $target_path . basename($folderName);
//upload file
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path."/")) {
echo "The file ". basename($_FILES['uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
$zip = new ZipArchive;
$res = $zip->open($target_path);
$target_path = str_replace(".zip", "", $target_path);
echo $target_path;
if ($res === TRUE) {
$zip->extractTo($target_path."/");
$zip->close();
echo "ok";
} else {
echo "failed";
}
似乎問題不在於Joomla,而是在PHP中。我用上面的代碼創建了一個簡單的文件,我用它來上傳一個大小爲5MB的文件,但它需要很長時間,並且失敗。 – themis 2012-02-24 19:54:31