vendredi 23 septembre 2016

shows me blank page when upload a .docx document on a website laravel

Hello I am new to laravel and still learning it and I come across different problems and issues and I cant find a way to solve it. I have been stuck to this since very long. Any help would be much appreciated.

The Problem

Whenever I upload a .docx file to my website i get a blank page without any error or without the content of that docx file. I dont know what the problem is. Please help me out with this.

Code

   public function getUploadedFile() {

     // $destinationPath = 'uploads';
    // $path= public_path()."/". $destinationPath;

    // $content = utf8_encode(File::get('/var/www/html/asad/File-Uploader/public/uploads/detailed_period_report_template.xls'));
    // return view('/files', compact('path'));


    $file = $this->request->file('file_name');
    $file_name = $this->request->file_name;

    if (File::isFile($file_name))
    {
        $file_name = File::get($file_name);
        $response = Response::make($file_name, 200);
         $content_types = [
            'application/octet-stream', // txt etc
            'application/msword', // doc
            'application/vnd.openxmlformats-officedocument.wordprocessingml.document', //docx
            'application/vnd.ms-excel', // xls
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', // xlsx
            'application/pdf', // pdf
        ];
        // using this will allow you to do some checks on it (if pdf/docx/doc/xls/xlsx)
       $response->header('Content-Type', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');

        return $response;
    }

I dont have any view for this. Do I need one for this ? If yes what would be it like because every docx file has it's set of properties like font, size, etc unlike excel sheets where we just defines columns. Please help me out. Thank you in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire