虽然我试图在Windows机器上使用php上传文件,但工作正常:
<form action="php/bulk.php"
enctype="multipart/form-data" method="post">
<p>
Please specify a file below:<br>
</p>
<div>
<input id="datafile" type="file" name="datafile" size="40"><br>
<input type="submit" value="Upload File">
</div></form>
bulk.php上的代码:
$connector = new DbConnector();
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['datafile']['name']);
if(move_uploaded_file($_FILES['datafile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['datafile']['name']).
" has been uploaded. \n";
} else{
echo "There was an error uploading the file, please try again!";
?>
<form action="../addsamples.php">
<input type="submit" value="Go Back" />
</form>
<?php
exit (-1);
}
我尝试在服务器上传,而不是在那里工作!操作系统在这方面发挥了什么作用?我的服务器是red hat linux,测试m / c是windows
答案 0 :(得分:2)
最可能的问题是文件权限。运行Web服务器的用户(apache
我认为是否为red hat)是否具有php/uploads/
的写入权限?