我有一個問題搞清楚。如何實現cookie處理上傳的圖片名稱?如何在個人資料圖片上傳中實現cookie?
我有2個文件:
的index.php(在這裏你可以設置個人資料照片)。
<form action="setPicture.php" method="post" enctype="multipart/form-data" >
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
setPicture.php
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename($_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
如果用戶上傳的資料照片將被保存在數據/ IMG公司/管理,我必須使用源將其保存裏面的cookie,然後重定向到主頁面index.php與配置文件圖片設置。
有人可以幫助我理解實施嗎?
下面是我工作的完整代碼。 https://jsfiddle.net/u5c4sz6u/1/
首先你爲什麼要在cookie中保存源代碼?您可以使用該會話 –
在您的代碼中,您尚未上傳該文件。文件上傳代碼在哪裏? –
我沒有ideea如何使用cookie,這就是爲什麼im問一些幫助:),如果我嘗試上傳圖片,它會上傳它在數據/ img/admin PS:我去了餅乾教程,但我的頭不能理解它 –