I uploaded and downloaded something I wrote, but when I downloaded it, the file was damaged?
缺一个女朋友
缺一个女朋友 2017-10-13 20:12:37
0
1
1261

I wrote the upload and download function myself, but when I downloaded it, it said the file was damaged? The method is the same as what is written online.

The code is as follows:

$filename = $_GET['file'];
header("Content-Disposition:attachment;filename=".$filename);
header("Content-Length:".filesize($filename));
readfile($filename);


缺一个女朋友
缺一个女朋友

为人谋而不忠乎…

reply all(1)
寻觅 beyond

Does your form for uploading files have the attribute enctype='multipart/form-data'?

Then, is the type of the form item for uploading files set to file?

Then, does the uploaded file obtain relevant information from $_FILES[ ][ ]?

Then, are you sure you can get the file using the get method? Are you sure you want to use get method?

Then, do you specify the file type (MIME type header information) before downloading the file?

What is written online may not be correct. Read the manual. The manual is authoritative


  • reply 6666666
    极世 author 2017-10-14 13:01:04
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template