<td class="reg-txt-left">Profile Picture:</td>
<td class="reg-input-right">
<form action="profile_save_upload.php" method="post" enctype="multipart/form-data">
<?php
echo "<img src=\"../user/".$_SESSION['profileEmail']."/images/".$_SESSION['profilePic']."\" alt='Profile Picture' width='200px' height='200px' />"
?>
<input type="file" name="file" />
<input type="submit" name="submitProfilePic" id="button" value="Change Profile Picture" />
</form>
</td>
這裏是profile_save_upload.php腓 - move_uploaded_file不能正常工作
<?php session_start();
if(isset($_POST['submitProfilePic'])){
/*file saving*/
if ($_FILES["file"]["error"] > 0){
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else{
if (file_exists("../user/".$_SESSION['profileEmail']."/" . $_FILES["file"]["name"]))
{
include('../includes/dbcon.php');
/*update database*/
$sql = mysql_query("UPDATE users
SET picture = '".$_FILES["file"]["name"]."'
WHERE email = '".$_SESSION['profileEmail']."'");
header("Location: profileEdit.php");
}
else{
move_uploaded_file($_FILES["file"]["tmp_name"], "../user/".$_SESSION['profileEmail']."/" . $_FILES["file"]["name"]);
include('../includes/dbcon.php');
$sql = mysql_query("UPDATE users
SET picture = '".$_FILES["file"]["name"]."'
WHERE email = '".$_SESSION['profileEmail']."'");
header("Location: profileEdit.php");
}
}
}
?>
這是圖像文件名被保存到數據庫,但不能將文件夾
includes
dbcon.php
site
profileEdit.php
profile_save_upload.php
user
user1
[the image supposed to be moved here]
的層次在文件夾中。
有沒有人有一個想法,哪裏是錯誤的部分?在此先感謝
父文件夾的路徑是否有該文件夾結構的寫權限? –
是的,有... – Katherine
@EdwinAlex這個代碼工作時,我在本地主機。但當它已經在線時沒有工作 – Katherine