How to get full filepath when uploading files in PHP?

后端 未结 3 1255
花落未央
花落未央 2021-02-10 00:47

I really want to know how am I gonna get the full filepath when I upload a file in PHP?

Here\'s my my problem...

I am importing a csv file in PHP. Uploading a fi

3条回答
  •  情书的邮戳
    2021-02-10 01:30

    The ['name'] refers to the original filename on the users computer. That's no use to you, in particular because it might be empty. (Or it can contain fake values, causing a directory traversal exploit. So, just avoid it.)

    You need to use the ['tmp_name'] which is a server-absolute path like /tmp/upload85728 that can be used for fopen() or move_uploaded_file().

提交回复
热议问题