PHP $ _FILES ['file'] ['tmp_name']:如何保留文件名和扩展名? [英] PHP $_FILES['file']['tmp_name']: How to preserve filename and extension?

查看:872
本文介绍了PHP $ _FILES ['file'] ['tmp_name']:如何保留文件名和扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从表单上传doc文件并将其发送到电子邮件.我正在使用

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

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

问题是,它正在返回随机生成的文件名.因此,到达收件箱时,文件名是phpvwRGKN.dat(每次文件名都是随机的).

The problem is, it is returning a randomly generated file name. So, when it reaches the inbox, the filename is phpvwRGKN.dat (filename is random each time).

如何保留文件名和扩展名?

How can I preserve the filename and extension?

注意:我正在使用推荐答案

$_FILES['file']['tmp_name'];将包含服务器上文件的临时文件名.在您处理文件之前,这只是服务器上的占位符

$_FILES['file']['tmp_name']; will contain the temporary file name of the file on the server. This is just a placeholder on your server until you process the file

$_FILES['file']['name'];包含从用户计算机上传的文件的原始名称.

$_FILES['file']['name']; contains the original name of the uploaded file from the user's computer.

这篇关于PHP $ _FILES ['file'] ['tmp_name']:如何保留文件名和扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆