거래 웹 사이트를 만들고 있으며 사용자가 광고를 업로드하도록 만들려고합니다. 내가 작성한 코드는 localhost에서 실행할 때 오류없이 잘 실행됩니다. 하지만 사이트를 호스팅 한 다음 광고를 업로드하려고 할 때 "500 내부 서버 오류"가 발생했습니다. 코드를 변경하지 않았습니다.
submitad 파일
<html>
<head>
<title>Submit Ad</title>
<link rel="stylesheet" type="text/css" href="css/signup.css"/>
</head>
<?php
require('heading.php');
?>
<form class="submit-ad" action="submitad_validation.php" method="POST" enctype="multipart/form-data">
<h1 class="sign-up-title">Submit Ad</h1>
<input type="text" name="title" class="sign-up-input" placeholder="Title" required autofocus>
<input type="text" name="description" class="sign-up-input" placeholder="Description" required>
<input type="text" name="contact" class="sign-up-input" placeholder="Email ID" required>
<input type="text" name="price" class="sign-up-input" placeholder="Expected Price" required>
<select class="sign-up-input" name="categories" required>
<option value="mobile">Mobiles and Accessories</option>
<option value="laptop">Laptops and Accessories</option>
<option value="cars">Cars</option>
<option value="bikes">Bikes</option>
<option value="appliances">Home Appliances</option>
<option value="books">Books</option>
<option value="jewelery">Jewelery</option>
<option value="music">Musical Instruments</option>
<option value="pets">Pets</option>
</select>
<!-- Code to upload the image of the item -->
<input type="file" name="imageUpload" id="imageUpload">
<input type="submit" value="Submit Ad" name="submit" class="sign-up-button">
</form>
</html>
submitadvalidation 파일
<!--This page is used to get the ad data from the user and then store it in the database-->
<?php
require('connection.php');
session_start();
$title=$_POST['title'];
$description=$_POST['description'];
$value=$_POST['categories'];
$price=$_POST['price'];
$contact=$_POST['contact'];
$id=$_SESSION['user_id'];
if(isset($_POST['submit']))
{
//Process the image that is uploaded by the user
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["imageUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
if (move_uploaded_file($_FILES["imageUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["imageUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";}
$image=basename( $_FILES["imageUpload"]["name"],".jpg"); // used to store the filename in a variable
//storing the data in your database
$query= "INSERT INTO items VALUES ('$id','$title','$description','$price','$value','$contact','$image')";
mysql_query($query);
require('heading.php');
echo "Your add has been submited, you will be redirected to your account page in 3 seconds....";
//redirecting the user back to the account page after successful uploading of the ad
header( "Refresh:3; url=account.php", true, 303);
}
?>
아마도 업로드 폴더를 만들지 않았거나 업로드 폴더에 대한 쓰기 권한이 없거나 데이터베이스에 대한 잘못된 연결 매개 변수가있을 수 있습니다.
이것들을 확인하십시오
추신 : 오류 메시지를 활성화 할 수 있으면 즉시 문제를 찾습니다.)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다