簡體   English   中英

在在線托管網站后,嘗試使用帶有php和mysql的數據庫以插入發布形式上傳圖像時出錯?

[英]Error while trying to upload image in a insert post form using a database with php and mysql in after hosting the website online?

我正在嘗試使用帶有php和mysql的數據庫以插入發布的形式上傳圖像。 我托管了該網站。 托管后,我嘗試插入數據,但是會引發以下錯誤:

警告:move_uploaded_file(images / Penguins.jpg)[function.move-uploaded-file]:無法打開流:在第75行的C:\\ inetpub \\ vhosts \\ srkv9093.com \\ testsrkv \\ insert_post.php中,權限被拒絕

警告:move_uploaded_file()[function.move-uploaded-file]:無法將C:\\ inetpub \\ vhosts \\ srkv9093.com \\中的'C:\\ Windows \\ Temp \\ phpC2A4.tmp'移動到'images / Penguins.jpg'第75行的testsrkv \\ insert_post.php

編碼

<body>
<div>
<h2><a href="index.php">Logout</a></h2> 
<h2><a href="view_posts.php">View Post</a></h2>
</div>  

<form method="post" action="insert_post.php" enctype="multipart/form-data">
<table width="600" align="center" border="0">
<tr>
<td align="center" colspan="6" bgcolor="white">
<h1>Insert New Post Here</h1>                   
</td>
</tr>

<tr>
<td align="right">Post Title:</td>
<td><input type="text" name="title"></td>
</tr>

<tr>
<td align="right">Post Author:</td>
<td><input type="text" name="author"></td>
</tr>

<tr>
<td align="right">Post Keywords:</td>
<td><input type="text" name="keywords"></td>
</tr>

<tr>
<td align="right">Post Image:</td>
<td><input type="file" name="image"></td>
</tr>

<tr>
<td align="right">Post Content:</td>
<td><textarea name="content" cols="30" rows="15"></textarea> </td>
</tr>

<tr>
<td align="center" colspan="6"><input type="submit" name="submit" value="Publish Now"></td>
</tr>

</table>
</form>

<?php
include("includes/connect.php");

if(isset($_POST['submit'])) {

$post_title = $_POST['title'];
$post_date = date('d-m-y');
$post_author = $_POST['author'];
$post_keywords = $_POST['keywords'];
$post_content = $_POST['content'];
$post_image = $_FILES['image']['name'];
$image_tmp = $_FILES['image']['tmp_name'];

if($post_title=='' or $post_keywords=='' or $post_content=='' or $post_author=='' or $post_date=='') {
echo "<script>alert(Some field is empty')</script>";

exit();
}

move_uploaded_file($image_tmp, "images/$post_image");

$insert_query = "insert into posts (post_title, post_date, post_author, post_image, post_keywords, post_content) values ('$post_title', '$post_date', '$post_author', '$post_image', '$post_keywords', '$post_content')";

if(mysql_query($insert_query)) {
    echo "<center><h1>Post Published Successfully!</h1></center>";
}

}
?>

只是好奇,您的網站托管在Windows服務器還是Linux服務器上? 只有這樣,才能全面回答問題

我可以發表評論,但顯然有人提高了發表評論的聲譽,

從您的路徑來看,我想您正在使用Window主機。 因此,您需要將“ images”文件夾的寫入權限設置為“ Everyone User”帳戶。 (或至少是Internet訪客帳戶),您可以參考此鏈接以了解工作方式。 http://www.web-site-scripts.com/knowledge-base/article/AA-00427/0/Setup-correct-files-and-folders-access-permissions-ficiently.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM