0
頁腳包括在與包括代碼導致此頁面這樣頁腳DIV沒有顯示時,如果你想看到你是一個錯誤出現在上傳
<?php include "footer.php" ?>
<center><div id="content"><br>
<form method="post" enctype="multipart/form-data">
<input type="file" class="file" name="userfile"/><br>
<br>
<button name="upload" type="submit" value="Submit" class="upload">Upload</button>
</form>
<?php
if(isset($_POST['upload'])) {
$allowed_filetypes = array('.jpg','.jpeg','.png','.gif');
$max_filesize = 10485760;
$upload_path = 'useruploads/';
$description = $_POST['imgdesc'];
$filename = $_FILES['userfile']['name'];
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
if(!in_array($ext,$allowed_filetypes))
die('<h4>The file you attempted to upload is not allowed.');
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die('<h4>The file you attempted to upload is too large.');
if(!is_writable($upload_path))
die('<h4>You cannot upload to the specified directory, please CHMOD it to 777.');
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) {
$query = "INSERT INTO uploads (name, description) VALUES ($filename, $description)";
mysql_query($query);
echo '<h5>Your file upload was successful!';
} else {
echo '<h4>There was an error during the file upload. Please try again.';
}
}
?>
</div>
索引文件自我我有臨時上傳這個腳本到我的網站,所以你可以看到你的錯誤是自我嘗試和上傳不是圖像文件的東西,你會看到錯誤,我看到是否可以添加一個按鈕上傳完成後將其鏈接到圖片上
這裏也是頁腳代碼
<center><div id="footer">
<p>Copyright © OSPICTUREVAU 2014</p>
</div>
如果我不使用死亡,那麼任何人都可以上傳文件,即使它仍然會說錯誤 – user3430617
您可以將上傳腳本重定向到錯誤頁面。死亡陳述殺死了腳本的所有進一步執行。 – Gavin
不知道該怎麼做,哈哈 – user3430617