无法将上传的文档保存在文件目录中[解决]
我正在尝试上传文件并将其保存在目录中。我只能将其保存在数据库中,但不能保存在目录中。这是我正在使用的代码。
<?php
$uploadLocation = "document/";
$uploadMainTo = null;
$main_image_name = $_FILES['file_name']['name'];
$main_image_size = $_FILES['file_name']['size'];
$main_image_tmp = $_FILES['file_name']['tmp_name'];
$uploadMainTo = $uploadLocation.$main_image_name;
$moveMain = move_uploaded_file($main_image_tmp,$uploadMainTo);
if(isset($_POST["submit"]) && !empty($_FILES['file_name']['name'])){
$s_name1 = $_POST['s_name1'];
$s_num1 = $_POST['s_num1'];
$s_dept1 = $_POST['s_dept1'];
$s_phone1 = $_POST['s_phone1'];
$s_lesen1 = $_POST['s_lesen1'];
$datestart = $_POST['datestart'];
$dateend = $_POST['dateend'];
$destination = $_POST['destination'];
$purpose = $_POST['purpose'];
echo $query = $conn->query("INSERT into book (book_type,s_name1,s_num1,s_dept1,s_phone1,s_lesen1,datestart,dateend,destination,purpose,file_name,status,created_by,update_by) VALUES ('Normal','".$s_name1."','".$s_num1."','".$s_dept1."','".$s_phone1."','".$s_lesen1."','".$datestart."','".$dateend."','".$destination."','".$purpose."','"$main_image_name."','Proses','".$user."', NOW())");
if($query){
// $statusMsg = "The file ".$fileName. " has been uploaded successfully.";
echo "<script>";
echo "<script>alert('Booking Application already send to PIC ')</script>";
echo "<script>";
echo "window.location.href = 'list_normal.php?id=$user'";
echo "</script>";
}}?>
您好,只是想通知您,我已经通过调整系统文件夹属性和允许权限解决了这个问题。
i'm trying to upload file and save it in directory. i only able to save it in database but not in directory. here is the code that i'm using.
<?php
$uploadLocation = "document/";
$uploadMainTo = null;
$main_image_name = $_FILES['file_name']['name'];
$main_image_size = $_FILES['file_name']['size'];
$main_image_tmp = $_FILES['file_name']['tmp_name'];
$uploadMainTo = $uploadLocation.$main_image_name;
$moveMain = move_uploaded_file($main_image_tmp,$uploadMainTo);
if(isset($_POST["submit"]) && !empty($_FILES['file_name']['name'])){
$s_name1 = $_POST['s_name1'];
$s_num1 = $_POST['s_num1'];
$s_dept1 = $_POST['s_dept1'];
$s_phone1 = $_POST['s_phone1'];
$s_lesen1 = $_POST['s_lesen1'];
$datestart = $_POST['datestart'];
$dateend = $_POST['dateend'];
$destination = $_POST['destination'];
$purpose = $_POST['purpose'];
echo $query = $conn->query("INSERT into book (book_type,s_name1,s_num1,s_dept1,s_phone1,s_lesen1,datestart,dateend,destination,purpose,file_name,status,created_by,update_by) VALUES ('Normal','".$s_name1."','".$s_num1."','".$s_dept1."','".$s_phone1."','".$s_lesen1."','".$datestart."','".$dateend."','".$destination."','".$purpose."','"$main_image_name."','Proses','".$user."', NOW())");
if($query){
// $statusMsg = "The file ".$fileName. " has been uploaded successfully.";
echo "<script>";
echo "<script>alert('Booking Application already send to PIC ')</script>";
echo "<script>";
echo "window.location.href = 'list_normal.php?id=$user'";
echo "</script>";
}}?>
Hi, just want to inform that i already solve this problem by adjusting the system folder properties and allow permissions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论