我試圖動態上傳圖片。 HTML代碼是:Move_uploaded_file()函數顯示錯誤
<form method="post" action="" name="form1" id="form1" enctype="multipart/form-data">
<label for "file">Select Picture</label><br>
<input type="file" name="file" id="file"><br>
<input type="hidden" value="<?php echo $_POST['pic'];?>" name="pic">
<input type="submit" value="Upload" name="upload" id="upload"><br>
</form>
After I write the following code it is showing me the error: " move_uploaded_file() [function.move-uploaded-file]: The second argument to copy() function cannot be a directory " and "Unable to move 'C:\xampp\tmp\phpB67C.tmp' to 'images/' ". The php code for this is:
if(isset($_POST['upload'])){
$pic=$_POST['pic'];
move_uploaded_file($_FILES["file"]["tmp_name"], "images/".$pic); //."jpg");
}
請告訴我如何刪除錯誤,並能夠添加和查看圖片。
print_r($ _ POST);給你? – Sebastian
它給我陣列([圖片] => [上傳] =>上傳) – Shreya
更改isset($ _ POST ['upload'])isset($ _ FILES ['upload']) –