试图让人们将文件上传到此网站。我尝试时收到错误。让我知道你的想法。我顺便使用codeigniter
===== HTML =====
<div id="upload">
<form enctype="multipart/form-data" action="<?=current_url()?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" />
<br />
<input type="submit" value="Upload" />
</form>
<p><?=$uploadResult?></p>
</div>
===== PHP =====
if ($this->input->post()) {
$target_path = "../../uploads/";
$target_path = $target_path .basename($_FILES['uploadedfile']['name']);
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
$uploadResult = "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else {
$uploadResult = "There was an error uploading the file, please try again!"; /* <---- Error I get */
}
} else {
$uploadResult = 'didnt work at all';
}
echo $uploadResult;
$this->data['uploadResult'] = $uploadResult;
=====错误=====
遇到PHP错误 严重性:警告 消息:move_uploaded_file(../../ uploads / notes_USH.odt):无法打开流:没有这样的文件或目录 文件名:controllers / discovery.php 行号:158
答案 0 :(得分:0)
确保目录“../../uploads/”存在并且您具有写入权限。 PHP不会为你创建这个。
此外,CodeIgnter有一个类来处理文件上传(可能很有用)。您可以在docs。
中看到这一点答案 1 :(得分:0)
好的,所以这有点晚了,但我只是用codeigniters的东西重新制作了一些东西,经过一些修修补补后我才开始工作。