MP3 / MP4 PHP上传不起作用 [英] MP3 / MP4 PHP upload doesn't work
问题描述
我想上传一个MP3 / MP4文件。但是用目前的解决方案,只有图片被上传。
这个问题只是关于上传mp3 / mp4文件的核心功能 - 我有意识地排除任何安全检查或种类
PHP:
if(move_uploaded_file($ _ FILES [file] [tmp_name],uploads /。$ _FILES ['file'] ['name']))
{
echoSuccessfully Uploaded Images;
}
else
{
echo上传时出错;
$ b $ pre> file = this.files [i];
if(window.FileReader){
reader = new FileReader();
reader.onloadend = function(e){
//showUploadedItem(e.target.result,file.fileName);
};
reader.readAsDataURL(file);
if(formdata){
formdata.append(file,file);
$ b $ if(formdata)
{
$ .ajax(
{
url:upload.php,
类型:POST,
data:formdata,
processData:false,$ b $ contentType:false,
成功:函数(res)
{
document.getElementById(response)。innerHTML = res;
}
});
编辑:
我已经设定upload_max_filesize为32 MB。
我得到了服务器的响应:
(!)注意:未定义的索引:C:\wamp\www\musicplayer_www\public_html\4_upload\upload.php中的文件位于第3行
调用堆栈
#时间内存函数位置
1 0.0022 134720 {main}()..\upload.php:0
(!)注意:未定义索引:C:\wamp\\www中的文件\musicplayer_www\public_html\4_upload\upload.php on line 3
调用堆栈
#时间内存函数位置
1 0.0022 134720 {main}().. \load。 php:0
编辑2: HTML表单: / p>
< div id =main>
< h1> 1。将曲目上传到ftp< / h1>
< form method =postenctype =multipart / form-dataaction =upload.php>
< input type =filename =imagesid =imagesmultiple />
< button type =submitid =btnclass =btn btn-default>上传档案< / button>
< / form>
< div id =response>< / div>
< / form>
< / div>
编辑3:参考这,有更多的限制,我们不得不考虑:
post_max_size
upload_max_filesize
memory_limit
我觉得你的mp3,mp4文件太大了,可以检查一下<
c $ c>上传文件的最大允许大小在php.ini中,默认你可以用2Mb上传文件,更改 upload_max_filesize
然后重新启动服务器
I really despair at this problem. I already found some other threads that consider about this problem, but I don't found a solution for me.
I want to upload a mp3 / mp4 file. But with my current solution only pictures are being uploaded.
This question is only about the core functionality of upload a mp3 / mp4 file - I conscious exclude any security checks or kind of this.
PHP:
if(move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES['file']['name']))
{
echo "Successfully Uploaded Images";
}
else
{
echo "Error while uploading";
}
JS:
file = this.files[i];
if (window.FileReader) {
reader = new FileReader();
reader.onloadend = function(e) {
//showUploadedItem(e.target.result, file.fileName);
};
reader.readAsDataURL(file);
}
if (formdata) {
formdata.append("file", file);
}
if (formdata)
{
$.ajax(
{
url: "upload.php",
type: "POST",
data: formdata,
processData: false,
contentType: false,
success: function(res)
{
document.getElementById("response").innerHTML = res;
}
});
}
EDIT: I already set the upload_max_filesize to 32 MB.
I got this response from the server:
( ! ) Notice: Undefined index: file in C:\wamp\www\musicplayer_www\public_html\4_upload\upload.php on line 3
Call Stack
# Time Memory Function Location
1 0.0022 134720 {main}( ) ..\upload.php:0
( ! ) Notice: Undefined index: file in C:\wamp\www\musicplayer_www\public_html\4_upload\upload.php on line 3
Call Stack
# Time Memory Function Location
1 0.0022 134720 {main}( ) ..\upload.php:0
EDIT 2: HTML Form:
<div id="main">
<h1>1. upload track to ftp</h1>
<form method="post" enctype="multipart/form-data" action="upload.php">
<input type="file" name="images" id="images" multiple/>
<button type="submit" id="btn" class="btn btn-default">Upload Files!</button>
</form>
<div id="response"></div>
</form>
</div>
EDIT 3: In reference to this, there some more limits we have to consider:
post_max_size
upload_max_filesize
memory_limit
So the thought of bluesky is in the right direction.
I think your mp3,mp4 file too large, you can check Maximum allowed size for uploaded file
in php.ini, default you can upload file with 2Mb, change upload_max_filesize
and restart your server
这篇关于MP3 / MP4 PHP上传不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!