你好有經驗的程序員。我目前在我的../var/www/photos
文件夾中有目錄images/
和文件Dan.php
。PHP沒有在目錄中存儲圖像
當我在瀏覽器中使用Dan.php
時單擊上傳按鈕時,會顯示成功消息。雖然破碎的圖像正方形顯示出來。右鍵單擊時,我也無法在新選項卡中打開圖像。該圖像也不出現在images/
文件夾中。這裏是Dan.php
。我會感謝您的見解和幫助。
我也試過做chmod -R 777 ../var/www/photos/images
。
<!--I want you to use GD Library to Resize the image that is uploaded.
如果你明白這一點很快就好了,開始研究JS腳本裁剪
圖片爲資料圖片(比例應爲1:1) - >
<html>
<body>
<form action="<?php echo ($_SERVER['PHP_SELF']);?>" method="post" enctype="multipart/form-data">
<label for="file">Pictures</label>
<input type="file" name="file[]" id="file" accept="image/*" multiple="">
<button type="submit" name="send_album">Submit</button>
</form>
<?php
if(!is_dir('images')) {
mkdir('images');
}
if(isset($_POST['send_album'])) {
//for($x = 0; $x < 9; $x++)
$x = -1;
foreach ($_FILES["file"]["name"] as $firstNameKey => $arFileDescriptions) {
$x += 1;
if ($_FILES["file"]["error"][$x] > 0) {
echo "Error: " . $_FILES["file"]["error"][$x] . "<br>";
} elseif (file_exists("images/". $_FILES["file"]["name"][$x])) {
echo $_FILES["file"]["name"][$x] . " already exists. <br />";
} else {
move_uploaded_file($_FILES["file"]["tmp_name"][$x], "images/" . $_FILES["file"]["name"][$x] . '/');
echo "Stored in: " . "images/" . $_FILES["file"]["name"][$x] ."<br />";
echo '<img style="height:150px;" src="' . 'images/'. $_FILES["file"]["name"][$x] . '" /><br />';
echo "Upload: " . $_FILES["file"]["name"][$x] . "<br />";
echo "Type: " . $_FILES["file"]["type"][$x] . "<br />";
echo "Size: " . ($_FILES["file"]["size"][$x]/1024) . " kB<br />";
}
}
}
?>
</body>
</html>
這是一個答案或問題? – 2013-05-08 08:23:24
這不是一個正確的答案。請擴展它,解釋需要設置什麼價值等等。解釋原因也是有用的。 – 2013-05-08 08:23:53