» Update: February 10, 2020Latest version/revision: HERE.» Change log:May 27, 2018 > Fixed a serious security hole found on this script (by Mars)
August 02, 2019 > Using %encoded-folder% as the destination (by danny).
» To-do list:- Progress bar (when uploading)
- Show a link (to the uploaded file)
» ATTENTION: The text below, is left as-is (only as a reference), so, it's not recommended for public use, because in those previous/initials stages of this script, a serious security hole was found (that allowed access to any file on the entire hard disk hosting HFS), which was solved HERE (thanks to Mars). There is no need to panic, but if you use an old version, just be sure to restrict the access of this script only to yourself. It is recommended to always use the latest version.
Hi there! I was reading these wiki pages (
Template macros &
scripting commands), trying to being able to download and save an external file to the current folder (Remote upload), but I can't get it working.
Please check my code (in my example, there is an URL already loaded, of a
Tiny Core Linux ISO file). The following code works fine, but
it's NOT recommended as it could overload the RAM if you are downloading a big file (I only leave this as reference):
THIS CODE WORKS:<form method='post'>
URL: <input name='url' value="http://distro.ibiblio.org/tinycorelinux/9.x/x86/release/Core-9.0.iso">
<br>Filename: <input name='dest' value="%folder%Core-9.0-GOOD.iso">
<br><input type='submit'>
</form>
{.set|url|{.postvar|url.}.}
{.break|if={.not|{.^url.}.}.}
{.set|dest| {.or|{.filename|{.postvar|dest.}.}|{.filename|{.^url.}.}|downloaded.} .}
{.load|{.^url.}|var=data.}
{.and
| {.length|{.save| ./{.^dest.} |var=data.}.}
| Downloaded {.^dest.} for {.length|var=data.} bytes
.}
The following
is the recommended code by rejetto
here (chinking the file every 1MB), but it doesn't work as expected (the download has a never ending loop). This code not only doesn't work, but besides that, it also have missing the text "Downloaded Core-9.0.iso for 13256704 bytes" and the event doesn't get logged on HFS's log.
THIS CODE DOESN'T WORK: (why?)
<form method='post'>
URL: <input name='url' value="http://distro.ibiblio.org/tinycorelinux/9.x/x86/release/Core-9.0.iso">
<br>Filename: <input name='dest' value="%folder%Core-9.0-BAD.iso">
<br><input type='submit'>
</form>
{.set|url|{.postvar|url.}.}
{.break|if={.not|{.^url.}.}.}
{.set|dest| {.or|{.filename|{.postvar|dest.}.}|{.filename|{.^url.}.}|downloaded.} .}
{.set|from|0.}
{.set|chunk|1000000.}
{.save|{.^dest.}|.}
{.while|chunk|{:
{.load|{.^url.}|var=data|size={.^chunk.}|from={.^from.}.}
{.if|{.length|var=data.}
| {:{.append|{.^dest.}|var=data.}
{.inc|from|{.length|var=data.}.}
:}
| {:{.set|chunk|0.}:}.}
:}|timeout=0.}
Could someone point me where is the fault?... 