xsendFile is sending 0 byte file(damaged and corrupted)

I put the file to download in the web folder(publically accessible), I tried different approch to get it downloaded but getting 0byte file:

The first thing I tried(file is being downloaded but 0byte; and if I open, the message is saying file corrupted) :




  public function actionImage(){ 

\Yii::$app->response->xSendFile('Image.zip');

}



The seconde(getting 500 internal error) :


  public function actionImage(){ 

header('application/zip');

header('Content-Disposition:attachment;filename=Image.zip');

$path =Yii::getAlias("@webroot/Image.zip");

//echo $path; gives the path

//echo filesize($path.$file); is returning the file size

header('X-Sendfile: '.$path.$file); // $path.$file outside quotes

header('Content-Length: '.filesize($path.$file)); // Filesize

Yii::$app->end();

}

But if I type directly mydomain.com/Image.zip, it is downloading the file.

I don’t know how to process so that xsendfile works for me!!

Check the documentation - http://www.yiiframew…html#xSendFile()-detail

Under side effects it say "[color="#333333"]If this option is disabled by the web server, when this method is called a download configuration dialog will open but the downloaded file will have 0 bytes."[/color]

[color="#333333"]So, first thing would be to check if this option is enabled on your web server.[/color]