Home  >  Q&A  >  body text

I uploaded and downloaded something I wrote, but when I downloaded it, the file was damaged?

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);


缺一个女朋友缺一个女朋友2537 days ago1207

reply all(1)I'll reply

  • 寻觅 beyond

    寻觅 beyond2017-10-13 20:50:22

    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
    1
  • 极世

    6666666

    极世 · 2017-10-14 13:01:04
  • Cancelreply