First of all, I use ng-flow (html5 file upload extension on angular.js framework)
My files are uploaded, I log the event in console. But I don't understand where and how to save them.
Here is my html code, upload is called.
<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>
Here is my config
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
is called, and $_GET
is full with data,
<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>
but when I'm here what I have to do to save my files?
I tried to do move_uploaded_file()
on flowFilename
and flowRelativePath
but nothing append.
I'm new in js.
Thank you.
After you upload your image with flow.js, a new post request is sent to your server. You need to handle this POST request and manipulate the file afterwards.
If you are using Java + Spring MVC it would looks like
I just spent half a day working with ng-flow and wanted to post the solution to this for PHP. It doesn't take advantage of the chunking and resume functionality, I just needed something that would upload without a page refresh.
First, flow-init="{target: '/upload', testChunks:false}" Example
Second,
It should now POST a request to "/upload"..... in that request exists a $_FILES array.
one line of code saved the file for me:
If you are looking to control this through your angular controller, you can set the values like so:
and in your html add:
Don
Create a folder called uploads means where you moved the temp files to here then add the code in php script.
Look at the upload.php example script:
https://github.com/flowjs/flow.js/blob/master/samples/Backend%20on%20PHP.md