您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php如何设置文件上传路径

2024/2/25 14:57:18发布14次查看
php设置文件上传路径的方法:首先创建php示例文件;然后修改服务端处理代码;最后通过“move_uploaded_file”移动文件到目标路径即可。
推荐:《php视频教程》
php文件上传路径
假设上传的文件name值为upload
<input type="file" name="upload" />
服务端处理代码如下:
if(isset($_files['upload']) && !$_files['upload']['error']) { // 文件存在且不报错 $filename = $_files['upload']['name']; // 获取文件 $fileextension = pathinfo($filename); // 获取文件路径信息 $fileextension = $fileextension['extension']; // 获取文件后缀 $time = time(); // 根据时间戳区分 $destinationpath = "./../upload/"; // 目标文件夹 $newfilename = $destinationpath.$time.".".$fileextension; // 完整的url if(move_uploaded_file($_files['upload']['tmp_name'], $newfilename)) { // 移动文件到目标路径 echo("文件移动成功"); } else { die("文件路径出错"); } }
以上就是php如何设置文件上传路径的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product