javascript – 使用ng-flow保存上传的文件的方式和位置?

前端之家收集整理的这篇文章主要介绍了javascript – 使用ng-flow保存上传的文件的方式和位置?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
首先,我使用 ng-flow(html5文件上传的extension.js框架)

我的文件上传,我将该事件记录在控制台中.
但我不明白在哪里和如何拯救他们.

这是我的HTML代码,上传调用.

<div flow-init flow-files-submitted="$flow.upload()">   
<div class="drop" flow-drop ng-class="dropClass">
    <span class="btn btn-default" flow-btn>Upload File</span>
    <span class="btn btn-default" flow-btn flow-directory ng-show="$flow.supportDirectory">Upload Folder</span>
    <b>OR</b>
    Drag And Drop your file here
</div>

这是我的配置

app.config(['flowFactoryProvider',function (flowFactoryProvider) {
  flowFactoryProvider.defaults = {
    target: 'upload.PHP',permanentErrors: [404,500,501],maxChunkRetries: 1,chunkRetryInterval: 5000,simultaneousUploads: 4,singleFile: true
  };
  flowFactoryProvider.on('catchAll',function (event) {
    console.log('catchAll',arguments);
  });
  // Can be used with different implementations of Flow.js
  // flowFactoryProvider.factory = fustyFlowFactory;
}]);

upload.PHP调用,并且$_GET是满的数据,

<script>alert('alert' + array(8) {
  ["flowChunkNumber"]=>
  string(1) "1"
  ["flowChunkSize"]=>
  string(7) "1048576"
  ["flowCurrentChunkSize"]=>
  string(6) "807855"
  ["flowTotalSize"]=>
  string(6) "807855"
  ["flowIdentifier"]=>
  string(11) "807855-3png"
  ["flowFilename"]=>
  string(5) "3.png"
  ["flowRelativePath"]=>
  string(5) "3.png"
  ["flowTotalChunks"]=>
  string(1) "1"
}
)</script>

但是当我在这里我要做的是保存我的文件

我试图在flowFilename和flowRelativePath上执行move_uploaded_file(),但没有附加.

我是新的在js.

谢谢.

解决方法

看看upload.PHP示例脚本:

https://github.com/flowjs/flow.js/blob/master/samples/Backend%20on%20PHP.md

// init the destination file (format <filename.ext>.part<#chunk>
// the file is stored in a temporary directory
$temp_dir = 'temp/'.$_POST['flowIdentifier'];
$dest_file = $temp_dir.'/'.$_POST['flowFilename'].'.part'.$_POST['flowChunkNumber'];

猜你在找的JavaScript相关文章