試圖讓人們上傳文件到本網站。當我嘗試時出現錯誤。讓我知道你的想法。用笨林的方式無法上傳文件選項
===== 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;
==== =遇到ERROR =====
甲PHP錯誤 嚴重性:警告 消息:move_uploaded_file(../../上傳/ notes_USH.odt):未能打開流:沒有這樣的文件或目錄 文件名:controllers/discovery.php 行號:158
如果失敗,你應該得到一個錯誤或警告,它/他們說什麼?另外,由於您使用的是CodeIgniter,因此您可能需要查看http://codeigniter.com/user_guide/libraries/file_uploading.html – Tjkoopa 2012-03-06 23:04:13
添加了錯誤 – 2012-03-06 23:56:49
我嘗試使用其上傳的東西並且無法使其工作 – 2012-03-07 00:11:16