无法上传大文件
cant upload large files
我有一个用于上传视频的简单脚本。它适用于 16mb 的文件,但比未上传的文件更大。我在 xampp 本地主机上使用它。
我曾尝试更改 post_max_size 和 upload_max_size 的值,但没有成功'
没用。
上传大文件时没有任何反应,代码不执行 If 部分。请看下面的代码:
if(isset($_POST['upload_btn']))
{
$q3="select uid from user_profile where username='$uname'";
$row=mysql_fetch_assoc(mysql_query($q3));
$id=$row['uid'];
$name=$_FILES['file']['name'];
$desc=$_POST['vid_desc'];
$type_temp=$_FILES['file']['type'];
$type=substr($type_temp,-3);
$size=$_FILES['file']['size']/1024/1024;
$temp=$_FILES['file']['tmp_name'];
if($_POST['vid_title']=="")
{
$name=$_FILES['file']['name'];
}
else
{
$_FILES['file']['name']=$_POST['vid_title'];
$name=$_FILES['file']['name'].".".$type;
}
if($_FILES['file']['type']=="video/mp4"||$_FILES['file']['type']=="video/flv"||$_FILES['file']['type']=="video/avi"&&$_FILES['file']['size']>=0)
{
$row=mysql_fetch_assoc(mysql_query("select uid from user_profile where username='$uname'"));
$uid=$row['uid'];
$query="insert into video_info(vid_title,vid_desc,vid_type,vid_size,uid) values('$name','$desc','$type','$size',$uid)";
mysql_query($query);
move_uploaded_file($temp,"videos/".$name);
?>
<script type="text/javascript">
document.getElementById("success").innerHTML = "Video uploaded successfully!!!";
//alert("Video uploaded successfully!!!");</script>
<?php
}
else
{
?>
<script type="text/javascript">
document.getElementById("error").innerHTML = "<style='color:red;'>Format not supported!! Supported formats are .mp4, .flv, .avi";
//alert("");</script>
<?php
}
}
谢谢,希望有人能帮我解决这个问题。
检查您的 php.ini 文件,您应该有 2 个,一个用于 CLI,另一个用于 apache(如果那是您的堆栈)。根据您的问题判断,您只编辑了一个 php.ini 文件。编辑它们以满足您的需要。您应该编辑的值为:
upload_max_filesize = 10M
改成你需要的。此外,此设置可能会让您感兴趣:
Maximum number of files that can be uploaded via a single request
max_file_uploads = 20
编辑后重启apache。
我有一个用于上传视频的简单脚本。它适用于 16mb 的文件,但比未上传的文件更大。我在 xampp 本地主机上使用它。
我曾尝试更改 post_max_size 和 upload_max_size 的值,但没有成功' 没用。
上传大文件时没有任何反应,代码不执行 If 部分。请看下面的代码:
if(isset($_POST['upload_btn']))
{
$q3="select uid from user_profile where username='$uname'";
$row=mysql_fetch_assoc(mysql_query($q3));
$id=$row['uid'];
$name=$_FILES['file']['name'];
$desc=$_POST['vid_desc'];
$type_temp=$_FILES['file']['type'];
$type=substr($type_temp,-3);
$size=$_FILES['file']['size']/1024/1024;
$temp=$_FILES['file']['tmp_name'];
if($_POST['vid_title']=="")
{
$name=$_FILES['file']['name'];
}
else
{
$_FILES['file']['name']=$_POST['vid_title'];
$name=$_FILES['file']['name'].".".$type;
}
if($_FILES['file']['type']=="video/mp4"||$_FILES['file']['type']=="video/flv"||$_FILES['file']['type']=="video/avi"&&$_FILES['file']['size']>=0)
{
$row=mysql_fetch_assoc(mysql_query("select uid from user_profile where username='$uname'"));
$uid=$row['uid'];
$query="insert into video_info(vid_title,vid_desc,vid_type,vid_size,uid) values('$name','$desc','$type','$size',$uid)";
mysql_query($query);
move_uploaded_file($temp,"videos/".$name);
?>
<script type="text/javascript">
document.getElementById("success").innerHTML = "Video uploaded successfully!!!";
//alert("Video uploaded successfully!!!");</script>
<?php
}
else
{
?>
<script type="text/javascript">
document.getElementById("error").innerHTML = "<style='color:red;'>Format not supported!! Supported formats are .mp4, .flv, .avi";
//alert("");</script>
<?php
}
}
谢谢,希望有人能帮我解决这个问题。
检查您的 php.ini 文件,您应该有 2 个,一个用于 CLI,另一个用于 apache(如果那是您的堆栈)。根据您的问题判断,您只编辑了一个 php.ini 文件。编辑它们以满足您的需要。您应该编辑的值为:
upload_max_filesize = 10M
改成你需要的。此外,此设置可能会让您感兴趣:
Maximum number of files that can be uploaded via a single request
max_file_uploads = 20
编辑后重启apache。