PHP图像文件上传停止工作

时间:2016-08-04 08:52:50

标签: php nginx upload

我一直在使用我已经构建了很长时间的这个PHP脚本,而且直到最近才让文件上传停止工作。我还没有得到什么错误,PHP FPM文件上传设置为1000m,我在Nginx上运行。正确设置文件权限并使用777 perms进行测试。

这是我的剧本:

 

<?php

    session_start();
    
if(!isset($_SESSION["user"]) or !is_array($_SESSION["user"]) or empty($_SESSION["user"])) {
      // redirect to login page
}
$dbhost   = "*.com";
$dbname   = "*";
$dbuser   = "*";
$dbpass   = "*";
 
// database connection
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
// new data


$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);

/*
echo $target_file;

echo $imageFileType;
*/
					$date = date('Y-m-d') ."\n";
					$now = time(); $utc_time = $now - intval(date('Z', $now));
					$time = date('H:i:s', $now);
					$post_id=(uniqid());
					$MediaTxt = $_POST['MediaTxt'];

		if ($imageFileType == "jpg" || $imageFileType == "JPG")
			{ 
			$imageFileType = strtolower($imageFileType);
					$ip = $_POST['ip'];
					$UsrFName = $_POST['UsrFName'];
					$UsrLName = $_POST['UsrLName'];
					$UsrID = $_POST['UsrID'];
					$format = 'img';
					$file_format = 'jpg';
					$MediaTxt = $_POST['MediaTxt'];
					$author_id = $_POST['author_id'];
					$relation = $_POST['relation'];
					$MediaTxtNw = strip_tags($MediaTxt, '<h1><h2><h3><h4><h5><h6><img><video><audio><iframe><a>');
					
					$tag = $MediaTxtNw;
					
					preg_match_all("/(#\w+)/", $tweet, $tags);
					
					$tweet = $MediaTxtNw;
					
					preg_match_all("/(#\w+)/", $tweet, $matches);
					
					foreach($matches[0] as $child) {
					  $tags = $child . "\n" ;
					  $tagsnew = preg_replace('/#([\w-]+)/i', '$1', $tags);

					$sql = "INSERT INTO hashtags (tag,post_id,uid,time,date) VALUES ('$tagsnew','$post_id','$UsrID','$time','$date');";
					
						if ($conn->query($sql) === TRUE) {
						} else {
						}
					}
					

					
					$target_dir = ('../media/jpg/');
					$target_file = $target_dir . $post_id . $author_id .'.'.pathinfo($_FILES["fileToUpload"]["name"], PATHINFO_EXTENSION);
					$uploadOk = 1;
					$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
					(move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file));

					
					$sql = "INSERT INTO media (ip,date,time,firstname,lastname,userID,post_id,format,file_format,MediaTxt,author_id,relation) VALUES
					 (:sasa,:sasad,:sasadf,:sasafds,:sasafda,:sasdfhj,:sasdhadka,:sasdhadkas,:sasdhadkasdas,:sashasdas,:aauutthorrid,:rrhjkjahtn)";
					$q = $conn->prepare($sql);
					$q->execute(array(':sasa'=>$ip,':sasad'=>$date,':sasadf'=>$time,':sasafds'=>$UsrFName,':sasafda'=>$UsrLName,':sasdfhj'=>$UsrID,
					':sasdhadka'=>$post_id,':sasdhadkas'=>$format,':sasdhadkasdas'=>$file_format,':sashasdas'=>$MediaTxtNw,
					':aauutthorrid'=>$author_id,':rrhjkjahtn'=>$relation));
					
			}

1 个答案:

答案 0 :(得分:0)

尝试通过在某些地方放置一些die('test');代码来调试代码......然后,您可以查看代码获取和调试的位置。并将其放在代码之上:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

error_reporting(E_ALL);