php - 如何上传已经上传的文件
问题描述
服务器文件夹中有文件,我需要上传到其他文件夹中。它确实尝试过,但即使我无法从服务器中选择文件。没有 HTML。
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
?>
解决方案
您无法从服务器上传文件。所以需要将一个文件夹复制到另一个文件夹。谢谢你。
copy(file,to_file)
推荐阅读
- python - 如何使用 python 记录器计算错误?
- git - OVH:云网络和 Gitlab-CI
- oracle - HikariProxyConnection 无法转换为 oracle.jdbc.OracleConnection
- facebook-graph-api - Facebook 在尝试使用沙盒广告帐户创建自定义受众时抛出奇怪的错误
- javascript - 如何通过单击按钮从反应状态挂钩数组中删除对象
- c# - 将字符串 bool 值转换为 bool 的最清晰方法
- bash - 如何使用颜色设置变量并与bash左对齐
- c# - 每个单词的正则表达式首字母大写,以空格分隔,长度为 3 到 29 个字符...C#
- kotlin - 使用 Algolia Kotlin 客户端
- powershell - 为什么 export-csv 在 SQL Server 上的 Powershell 中无法正常运行?