나는 웹 사이트를 만들고 있으며 새 게시물을 추가하는 양식이 있습니다. 나는 IE에 대한 전폭적 인 지원을 위해 아약스 대신 iFrame을 사용하고있다. (좋아, IE는 가장 싫어하고 최악의 브라우저 중 하나이지만 일부 멍청이는 그것을 사용하고있다.) 기본적으로 양식을 제출하면 내부 오류가 발생합니다 (500).PHP로 업로드
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionic/1.3.2/css/ionic.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<form enctype="multipart/form-data" class="form" id="form" action="./addPost.php" method="POST">
<div class="list">
<label class="item item-input">
<input type="text" placeholder="Title" class="AddPosttitle" name="title">
</label>
<label class="item item-input">
<input class="description" type="text" placeholder="Simple Description (max 60 caracters)" maxlength="60" name="description">
</label>
<label class="item item-input">
<div>
<span id='button_upload'>Image : </span>
<input type='file' class="img" name="img">
</div>
</label>
<label class="item item-input">
<textarea placeholder="Full description" class="full" name="full"></textarea>
</label>
<div class="padding">
<button class="button button-block button-positive submit-btn" type="submit">
Submit
</button>
</div>
</div>
</form>
<style type="text/css">
.form {
background: #FFF;
}
</style>
<?php
if (!empty($_GET['error'])){
?>
<script type="text/javascript">
function findGetParameter(parameterName) {
var result = null,
tmp = [];
var items = location.search.substr(1).split("&");
for (var index = 0; index < items.length; index++) {
tmp = items[index].split("=");
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
}
return result;
}
alert(findGetParameter("error"));
</script><?php
}
?>
나는 일부 구성 요소를 사랑해서, 이오니아 라이브러리를 사용하고 있지만, 어쨌든이 내 addPost.php
파일입니다 :
<?php
try
{
$db = new PDO('mysql:host=something;dbname=someDB;charset=utf8', 'ID', 'LOL');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$post = $_POST;
$img = base64_encode(file_get_contents($_FILES['img']['tmp_name']));
$title = addslashes($post['title']);
$description = addslashes($post['description']);
$fullDesc = addslashes($post['full']);
// if (!empty($title) & !empty($description) & !empty($fullDesc) & !empty($img)) {
// }
// else {
// // header("Location: form.php?error=Fill the form!");
// }
$sql = "INSERT INTO posts (title, description, img, fullDesc, likes) VALUES ('$title', '$description', hextoraw('$img')', '$fullDesc', 0)";
$db->exec($sql);
// header("Access-Control-Allow-Origin: *");
header("Location: form.php?error=$sql");
내가 왜 모르는 여기 내 양식입니다 오류가 있습니다. 나는 이미지에서 오는 것이라고 생각하지만 확실하지 않습니다. 나는 여전히 궁극적 인 해결책을 찾으려고 노력 중이다. 무언가를 찾으면 내 질문을 편집한다.
게시물에 삽입 할 때 추가 인용이 있습니다. 당신에게 알려주기 위해서. – Nello
'hextoraw'가 무엇이든 문자열을 사용하여 함수를 호출 할 수 없습니다. –