[英]cant upload audio file php
hi i cant upload audio file with this code, its the same code i used for image upload but its not working for video and audio. 嗨,我无法使用此代码上传音频文件,其代码与我用于图像上传的代码相同,但不适用于视频和音频。 And yes i changed the values in php.ini but yet it is still the same
是的,我更改了php.ini中的值,但仍然相同
<?php
if(isset($_POST['submit'])){
$uploaderror='';
$target_dir = "../user/henboc/";
$target_file = $target_dir . basename($_FILES["userfile"]["name"]);
//$file_size = $_FILES['userfile']['size'];
$file_name = $_FILES['userfile']['name'];
$temp_dir = $_FILES["userfile"]["tmp_name"];
$ext_str = "jpg,jpeg,png,mp3,tiff,bmp,doc,docx,txt,pdf,ppt,pptx";
$ext = substr($file_name, strrpos($file_name, '.') + 1);
$allowed_extensions=explode(',',$ext_str);
if (move_uploaded_file($temp_dir, $target_file)){
echo '<div class="alert alert-danger">
<strong>Error!</strong> Name already exist
</div>';
}
//
}
?>
and my html 和我的HTML
<form class="form-horizontal form-label-left" method="post" action="" enctype="multipart/form-data" role="form">
<br>
<label for="fullname">Upload Music</label>
<input type="file" class="form-control" name="userfile" id="userfile" />
<br>
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<button type="" class="btn btn-primary">Cancel</button>
<button type="submit" class="btn btn-success" name="submit">Submit</button>
</div>
</div>
</form>
MY php.ini 我的php.ini
post_max_size = 24M
upload_max_filesize = 20M
Okay your PHP script seems to be working fine for me. 好的,您的PHP脚本对我来说似乎很好。 Here are the steps you should check:
这是您应检查的步骤:
action=""
attribute of your form tag. action=""
属性。 If your problem still persists you may want to use this snippet for getting specific information about the error cause. 如果问题仍然存在,则可能需要使用此代码段来获取有关错误原因的特定信息。
post_max_size = 24M
upload_max_filesize = 20M
This is not all that needs tuning. 这不是全部需要调整的。 As file uploads goes via
POST
request, you must have also ensure that all timeouts are not reached before upload is completed, so ie max_execution_time
and max_input_time
. 由于文件上传是通过
POST
请求进行的,因此您还必须确保在上传完成之前未达到所有超时,例如max_execution_time
和max_input_time
。 I'd also check error log. 我还要检查错误日志。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.