这是我的php eror日志:
[Thu Dec 18 02:40:20.918991 2014] [:error] [pid 6164] [client 127.0.0.1:55890] PHP Notice: Undefined index: file in /var/www/html/pages/addimage.php on line 3, referer: http://localhost/pages/home.php
[Thu Dec 18 02:40:20.919054 2014] [:error] [pid 6164] [client 127.0.0.1:55890] PHP Notice: Undefined index: file in /var/www/html/pages/addimage.php on line 3, referer: http://localhost/pages/home.php
[Thu Dec 18 02:40:20.919344 2014] [:error] [pid 6164] [client 127.0.0.1:55890] PHP Notice: Undefined index: file in /var/www/html/pages/addimage.php on line 5, referer: http://localhost/pages/home.php
[Thu Dec 18 02:40:25.686317 2014] [:error] [pid 6163] [client 127.0.0.1:55901] PHP Notice: Undefined index: file in /var/www/html/pages/addimage.php on line 3, referer: http://localhost/pages/home.php
[Thu Dec 18 02:40:25.686355 2014] [:error] [pid 6163] [client 127.0.0.1:55901] PHP Notice: Undefined index: file in /var/www/html/pages/addimage.php on line 3, referer: http://localhost/pages/home.php
[Thu Dec 18 02:40:25.686518 2014] [:error] [pid 6163] [client 127.0.0.1:55901] PHP Notice: Undefined index: file in /var/www/html/pages/addimage.php on line 5, referer: http://localhost/pages/home.php$
我的代码:
<?php
if(isset($_POST["submit"])){
move_uploaded_file($_FILES["file"]["tmp_name"],"../img/profile_picture/" . $_FILES['file']['name']);
$con=mysqli_connect("localhost","root", "verdun1914", "HateBook");
$q=mysqli_query($con,"UPDATE websiteusers SET image_url='". "../img/profile_picture/". $_FILES['file']['name']."' WHERE username = '".$_SESSION['sess_username']."'");
}
?>
<div class="addimage-screen">
<div id="banner_wrap">
<div class="banner-content">
<div class="addimage-form" id="Sign-Up">
<p><h3>ADD IMAGE<h3></p>
<form id="register-form" method="POST" enctype="multipart/form-data" action="">
<input type="file" name="file"><br>
<input id="button" class="btn btn-primary btn-lg btn-block" type="submit" name="submit" value="Upload">
</form>
</div>
</div>
</div>
</div>
当在新窗口中打开此.php文件时,它实际上工作正常,甚至将文件上传到我的服务器。现在我只包含此文件,它不会将文件上传到服务器。
但是!在我的数据库中,它仍会保存此链接:../img/profile_picture/
。
谢谢·