PHP $_FILES['file']['tmp_name']: How to preserve filename and extension?

后端 未结 6 1140
谎友^
谎友^ 2020-12-09 16:25

I am trying to upload a doc file from a form and send it to email. I am using

$_FILES[\'file\'][\'tmp_name\'];

The problem is, it is retur

6条回答
  •  眼角桃花
    2020-12-09 16:58

    If you wanna get the uploaded file name, use $_FILES["file"]["name"]

    But If you wanna read the uploaded file you should use $_FILES["file"]["tmp_name"], because tmp_name is a temporary copy of your uploaded file and it's easier than using

    $_FILES["file"]["name"] // This name includes a file path, which makes file read process more complex

提交回复
热议问题