Hello Tanaike,
i found your solution on a stackoverflow post and i find it highly interesting, as it seems to be the perfect solution for my problem.
When i paste the apps script code into the script editor and try to save, it gives me a syntax error at this line in the "upload" section of the function:
[parseInt(i, 10) for each (i in p.file)],
The error is "Unexpected Token 'for'"