【发布时间】:2017-11-07 20:12:54
【问题描述】:
我正在使用 XAMPP 在我的 Windows 笔记本电脑上测试此代码,没有问题。但是当我在我的 mac book 上运行时,我要上传的文件没有保存在上传文件夹中。对我有什么解决方案吗? 这是我的php代码
<?php
$conn=new PDO('mysql:host=localhost; dbname=xxx', 'root', '') or die(mysql_error());
if(isset($_POST['submit'])!=""){
$title = $_POST['title'];// file title
$date = $_POST['date'];// file date
$ref = $_POST['ref'];// file ref
$ftype = $_POST['ftype'];// file ref
$from_to = $_POST['from_to'];// person incharge
$details = $_POST['details'];// details
$location = $_POST['location'];// file location
$status = $_POST['status'];// file status
$name=$_FILES['photo']['name'];
$size=$_FILES['photo']['size'];
$type=$_FILES['photo']['type'];
$temp=$_FILES['photo']['tmp_name'];
move_uploaded_file($_FILES,"upload/".$name);
$query=$conn->query("INSERT INTO upload(title, date, ref, ftype, from_to, details, location, status, name)VALUES('$title', '$date', '$ref', '$ftype', '$from_to', '$details', '$location', '$status', '$name')");
if($query){
header("location:view.php");
}
else{
die(mysql_error());
}
}
?>
这是我的表格
<form enctype="multipart/form-data" action="" name="form" method="post">
<table class="table table-bordered table-responsive">
<tr>
<td><label class="control-label">Reference Number</label></td>
<td><input class="form-control" type="text" name="ref" placeholder="Reference Number" required /></td>
</tr>
<tr>
<td><label class="control-label">File Name</label></td>
<td><input class="form-control" type="text" name="title" placeholder="File Name" required /></td>
</tr>
<tr>
<td><label class="control-label">Type</label></td>
<td><p><select name="ftype" required >
<option value="Correspondence">Correspondence</option>
</select></p></td>
</tr>
<tr>
<td><label class="control-label">Date</label></td>
<td><input class="form-control" type="date" name="date" placeholder="Date" required /></td>
</tr>
<tr>
<td><label class="control-label">Person Incharge</label></td>
<td><input class="form-control" type="text" name="from_to" placeholder="Person Incharge" required /></td>
</tr>
<td><label class="control-label">Details</label></td>
<td><textarea class="form-control" name="details" placeholder="Details" required ></textarea> </td>
</tr>
<td><label class="control-label">Location</label></td>
<td><p><select name="location" required >
<option value="Admin">Admin</option>
</select></p></td>
</tr>
<td><label class="control-label">Status</label></td>
<td><p><select name="status" required >
<option value="Active">Active</option>
</select></p></td>
</tr>
<tr>
<td colspan="2"><p>Attach File<input type="file" name="photo" id="photo" required />
<input type="submit" name="submit" id="submit" value="Submit" />
</td>
</tr>
</table>
</form>
【问题讨论】:
-
你检查过上传目录的权限并确保它可以被PHP写吗?
-
你的意思是在 php.ini 中?我已经检查过了。
-
没有。我的意思是实际的文件系统。
-
file_uploads=开启
-
先生,我该如何检查?
标签: php pdo phpmyadmin