dongtuo4132 2018-08-29 13:06
浏览 81

如何实现blueimp fileuploader的最基本版本并使用php将文件保存在我的服务器上

I am trying to implement the blueimp jquery fileuploader. but there are so many options that I do not need.

All I am trying to accomplish is a simple upload form which saves the file (all files allowed) in a folder on my server.

I've followed this guide: https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin

And it works in the sense that I am able to send data to my PHP file (which at the moment is empty).

In my network tab this is what is sent:

------WebKitFormBoundaryJAh0SYem6x65yoGw
Content-Disposition: form-data; name="files[]"; filename="199370898.pdf"
Content-Type: application/pdf


------WebKitFormBoundaryJAh0SYem6x65yoGw--

I can't find in the tutorials what to do after this. On their wiki there are only tutorials for frameworks like Zend/CakePHP but I am not using a framework.

I'll probably can figure out how to get the filename using the form-data but where is the actual file itself?

I've made an upload script for images myself before which sent a base64 string, I don't see anything like that here.

My JS:

<script>
$(function () {
    $('#fileupload').fileupload({
        dataType: 'html',
        progressall: function (e, data) {
        var progress = parseInt(data.loaded / data.total * 100, 10);
        $('#progress .bar').css(
            'width',
            progress + '%'
        );
    },
        done: function (e, data) {
            $.each(data.result.files, function (index, file) {
                $('<p/>').text(file.name).appendTo(document.body);
            });
        }
    });
});
</script>

HTML:

<input id="fileupload" type="file" name="files[]" data-url="includes/uploadhandler.php">
<div id="progress">
    <div class="bar" style="width: 0%;"></div>
</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题