0
我一直在試圖讓這個文件/表單上傳工作,但是當我上傳表單時,一個空白頁面沒有任何錯誤發生。上傳圖片和表格
上傳圖像文件名+路徑到SQL和實際圖像應該去/上傳地圖。
錯誤檢查的任何建議?
這裏是我的代碼
<?php
if (isset($_POST['update']))
{
$dbhost = 'localhost';
$dbuser = 'heijsdb_user';
$dbpass = 'maus';
$conn = ($GLOBALS["___mysqli_ston"] = mysqli_connect($dbhost, $dbuser, $dbpass));
$controleur = $_SESSION["username"];
$constatering = $_POST['constatering'];
$radio = $_POST['radio'];
$actie = $_POST['actie'];
$date = $_POST['geplande_datum'];
$verant = $_POST['verantwoordelijke'];
$toelichting = $_POST['toelichting'];
$filename = $_FILES['file']['name'];
$filetype = $_FILES['file']['type'];
if ($filetype == 'image/jpeg' or $filetype == 'image/png' or $filetype == 'image/jpg')
{
$move = move_uploaded_file($_FILES['file']['tmp_name'], './uploads/a' . $filename);
$filepath = "./uploads/a" . $filename;
if ($move)
{
echo "goed geupload";
}
else
{
echo "mis";
}
if (!$conn)
{
die('Could not connect: ' . mysqli_error($GLOBALS["___mysqli_ston"]));
}
$sql = "INSERT INTO logboek_afwijkingen (controleur, image, constatering, besmetting, actie, datum_gepland, verantwoordelijke, toelichting)
VALUES ('$controleur','$filepath', '$constatering', '$radio', '$actie', '$date', '$verant', '$toelichting')";
mysqli_select_db($GLOBALS["___mysqli_ston"], 'heijsdb');
$retval = mysqli_query($conn, $sql);
if (!$retval)
{
die('Could not update data: ' . mysqli_error($GLOBALS["___mysqli_ston"]));
}
echo "Form send.";
((is_null($___mysqli_res = mysqli_close($conn))) ? false : $___mysqli_res);
}
}
else
{
?>
<form method = "post" action = "<?php
$_PHP_SELF ?>" id="form1" enctype="multipart/form-data" class="w3-padding w3-main">
<fieldset id="f1"><b>Logboek afwijkingen</b></fieldset>
<table width= "600" border="1" cellspacing="1" cellpadding="1" class="w3-container w3-table">
<tr><td width="200"><b>upload foto</b></td><td></td> <td width="100"><input type="file" size="3" name="file"></td></tr>
<tr><td width="200"><b>constatering</b></td><td></td> <td width="100"><textarea style="margin: 0px; width: 252px; height: 94px;" name="constatering"></textarea></td></tr>
<tr>
<td width="100"><b>kans op acute besmetting</b></td>
<td></td>
<td><input type="radio" value="ja" class="w3-radio" name="radio"> Ja<br />
<input type="radio" value="nee" class="w3-radio" name="radio"> Nee<br /></td></tr>
<tr>
<td width="100"><b>corrigerende actie</b></td>
<td></td>
<td><textarea style="margin: 0px; width: 150px; height: 60px;" name="actie"></textarea></td>
</tr>
<tr>
<td width="100"><b>geplande datum</b></td>
<td></td>
<td><input type="date" size="3" name="geplande_datum"></td>
</tr>
<tr>
<td width="100"><b>verantwoordelijke</b></td>
<td></td> <td>
<input type="text" size="3" name="verantwoordelijke"></td>
</tr>
<tr>
<td width="100"><b>Toelichting</b></td>
<td></td>
<td><textarea style="margin: 0px; width: 252px; height: 94px;" name="toelichting"></textarea></td>
</tr>
</table>
<input type="submit" name="update" value="update" class="w3-bar w3-red" action="<?php
echo $_SERVER['PHP_SELF']; ?>">
</form>
<?php
}
?>
你的代碼是不是正確的,你應該使用MVC結構。 – Webinion
檢查你的php error.log。 – VirCom
白頁通常是PHP錯誤。如果您不能訪問error.log,請嘗試'ini_set('display_errors',true);'作爲第一個PHP指令將其調試到瀏覽器中。 –