Reputation: 383
I need to download file from folder /uploads, but I just get timeOut error when the action is called, Anyone can help me :(
public function actionDownload() {
$path = Yii::getAlias('@webroot') . '/uploads';
$file = $path . '/1.pdf';
if (file_exists($file)) {
Yii::$app->response->sendFile($file);
}
}
Upvotes: 7
Views: 25343
Reputation: 2154
If a download takes too much time, I see 2 possibilities
ini_set('max_execution_time', 5*60); // 5 minutes
if (file_exists($file)) {
Yii::$app->response->xSendFile($file);
}
Upvotes: 8