0
在我的網站上,我想用PHP在服務器上傳圖片。但這個東西適用於小尺寸圖片,但不適合大尺寸圖片。我只想上傳移動點擊的圖片。這裏是我的形式上傳圖像大尺寸圖片不在服務器上使用PHP上傳
<form action="newupload.php" enctype="multipart/form-data" method="post">
<div class="form-group">
<div id="image-cropper">
<input type="file" name="user_image" class="cropit-image-input" style="font-weight: bold;" />
</div>
</div>
<div class="form-group">
<input type="text" name="title" class="input-round big-input" id="title-modal" placeholder="Enter your Image Title" required/>
</div>
<div class="form-group">
<!-- required -->
<span class="required margin-three">*Please complete all fields correctly</span>
<!-- end required -->
<p class="text-center">
<button class="btn btn-black no-margin-bottom btn-medium btn-round no-margin-top" type="submit" id="submitbtn">Submit</button>
</p>
</div>
</form>
這裏是我上傳的PHP腳本:
$errors = 0;
error_reporting(E_ALL);
require_once 'mysqli_connect.php';
session_start();
$email = $_SESSION['user_email'];
$q = "select * from user where u_email='$email'";
$qres=mysqli_query($dbc,$q);
$qrow=mysqli_fetch_array($qres,MYSQLI_ASSOC);
$u_id=$qrow['u_id'];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!empty($_FILES['user_image']['name']) && !empty($_POST['title'])) {
$image = $_FILES['user_image']['name'];
$uploadedfile = $_FILES['user_image']['tmp_name'];
$image_title = $_POST['title'];
$t = uniqid();
$filenamee = 'user-'.$t;
$path = 'uploaded/';
$filename = $path.$filenamee.".jpg";
if (move_uploaded_file($_FILES['user_image']['tmp_name'], $filename)) {
$query = "insert into selfiepost (u_id,s_title,s_upload,upload_time) v values ('$u_id','$image_title','$filename',now())";
$res = mysqli_query($dbc, $query);
if ($res) {
header('Location:home.php?insert=1');
} else{
header('Location:home.php?insert=0');
}
} else {
echo "Sorry, File not uploaded successfully. Please try again!!";
}
} else {
echo "Files should not be empty!!";
}
}
我php.ini
文件只包含這五兩件事:
upload_max_filesize 20M
post_max_size 40M
max_input_time 180
max_execution_time 60
memory_limit 48M
訪問並使用http://php.net/manual/en/features.file-upload.errors.php --- http://php.net/manual/en/function.error-reporting.php和用'phpinfo()'查看你係統的信息。 –
使用此鏈接:-https://www.sitepoint.com/upload-large-files-in-php/。將這些代碼添加到您的php文件中,並檢查 –
您在上傳時是否在網絡/控制檯選項卡中的瀏覽器(通過F12)中看到錯誤?你看到服務器上的apache或php日誌中有任何錯誤嗎?什麼是PHP.ini中定義的錯誤級別? – Cagy79