将输入文件保存到另一个文件夹中php
问题描述:
我是初学php。将输入文件保存到另一个文件夹中php
我发现使用MySQL数据库和文件的最佳工具是php。
所以我需要从“FILE_NAME”
<input type=file name="file_name">
获取文件,并保存此文件到另一个地方。例如在D:/文件夹/
请告诉我,我该怎么做在PHP中。或者还有另一种途径来解决这个问题
答
$target_dir = "uploads/"; // folder path
$target_file = $target_dir . basename($_FILES["fileToUpload"]["file_name"]);
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
答
确保在HTML表单标签添加ENCTYPE = “的multipart/form-data的”。否则你不会得到$ _FILE arr
检查此帖:http://*.com/questions/3509333/how-to-upload-save-files-with-desired-name – Izion 2015-02-11 12:49:51
可能重复的[PHP文件上传](http://*.com/questions/1673393/php-file-upload) – 2015-02-11 12:51:08
只是一个额外的注意,这个网站是有用的,如果你新的PHP:http://www.w3schools.com/php/ – Izion 2015-02-11 12:51:24