我在上传文件时遇到问题。上传7mb视频时,$ _FILES ['video'] ['tmp_name']为空,当我上传15mb文件时,表单实际上并未“提交”,实际上只是刷新。
以下是我处理提交的代码:
if(isset($_POST['submit'])){
$blah = "".$_FILES['video']['size']."";
var_dump($blah);
if( empty($_FILES['video']) && empty($_POST['create_video']) ){
echo "<div class='alert alert-danger' role='alert'><center><strong>Missing Fields:</strong> Please choose a video or request the ##### team create a video.</center></div>";
} else {
if( empty($_FILES['video']['name']) && $_POST['create_video'] == "true" ){
$_SESSION['create_video'] = protect($_POST['create_video']);
?>
<script type="text/javascript">
window.location = "NEXT_PAGE";
</script>
<?
exit();
}else{
//if all were filled in continue
$allowedExts = array("mp4", "MP4", "m4a");
$extension = pathinfo($_FILES['video']['name'], PATHINFO_EXTENSION);
if ( ($_FILES["video"]["size"] <= 15728640) && (in_array($extension, $allowedExts)) ) {
if ($_FILES["video"]["error"] > 0){
echo "Return Code: " . $_FILES["video"]["error"] . "<br />";
}else{
//Get the height and width of our video
//$getID3 = new getID3;
//$file = $getID3->analyze($_FILES["video"]["tmp_name"]);
//$width =$file['video']['resolution_x'];
//$height = $file['video']['resolution_y'];
$img = getimagesize($_FILES['video']['tmp_name']);
$width = $img[0];
$height = $img[1];
var_dump($width); var_dump($height);
if( ($height < 719) || ($width < 1279)){
echo "<div class='alert alert-danger' role='alert'><center><strong>Invalid file dimensions</strong> Please ensure your image is the correct size.</center></div>";
} else {
$ext = findexts ($_FILES["video"]["name"]);
$ran = rand ();
$file_name = $_FILES["video"]["name"] = "".$_SESSION['uid'] ."".$ran.".".$ext."";
if (file_exists("uploads/video_ads/".$_SESSION['uid']."_" . $_FILES["video"]["name"])){
echo $_FILES["video"]["name"] . " already exists. ";
}else{
move_uploaded_file($_FILES["video"]["tmp_name"],
"uploads/video_ads/".$_SESSION['uid']."_" . $_FILES["video"]["name"]);
//Save the link of our ad
$_SESSION['video'] = "####/uploads/video_ads/".$_SESSION['uid']."_" . $_FILES["video"]["name"]."";
$_SESSION['create_video'] = protect($_POST['create_video']);
?>
<script type="text/javascript">
window.location = "NEXT_PAGE";
</script>
<?
exit();
}
}
}
} else {
echo "<div class='alert alert-danger' role='alert'><center><strong>Invalid file type</strong> Please upload a video in MP4 format.</center></div>";
}
}
}
}
这是我的实际形式:
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" class="form-signin" role="form" enctype="multipart/form-data">
<br />
<input type="file" name="video" id="video" /><br />
<br />
<div class="row">
<div class="col-md-12">
<strong class="ad-header"
style="font-size: 150%; font-weight: bold;">Quick Tips:</strong>
</div>
</div>
<hr>
<h3 class="ad-sub-header" style="color: #559fd3; font-size: 150%;">Need
help to create engaging artwork for your brand?</h3>
<strong class="ad-header" style="font-size: 100%;">####
has the creative team to get it done for you</strong><br /> Only ##/hr -
3 revisions - Artwork is yours to keep. <br />
<br /> <input type="checkbox" name="create_video" value="true" />
I don't have an ad. Please create one. <br />
<br /> <input class="btn btn-lg btn-primary btn-block"
type="submit" name="submit" value="Continue To Step 5" />
</form>
答案 0 :(得分:2)
可能性是您的服务器不接受大于2M的上传。您需要检查phpinfo()
(如果您有权访问它,请检查php.ini)以查看您当前的限制。如果它仅为2M或小于您的上传大小,则需要对其进行编辑以允许更大的上传。如果你在共享主机上,你可能会运气不好。
答案 1 :(得分:0)
尝试使用以下设置调整php.ini:
php_value memory_limit 96M
php_value post_max_size 96M
php_value upload_max_filesize 96M
并确保file_uploads
设置位于On
答案 2 :(得分:0)
对于有此问题的任何人。我不得不增加post_max_size,默认设置为8M。