Hi, I am working my way through server side downloading files with Routing. I followed the tutorial on static server side downloading with routing and that worked fine, even with Routing parameters, all is good so far.
I am taking baby steps to move forward and I wish to use Dynamic values for the Download but this has caused some unexpected results.
My routing is defined as …
When called from an Anchor button with the Link set to a static value…
it works beautifully and a download of the file occurs.
I then defined 4 variables in the App to check that the link will work with dynamic values rather than static values. Each valuable, for now, is set to the same values you see above.
But the effect of this is that the download will not work. When I click on the anchor button, the page blanks entirely, no error message is displayed, no file is downloaded.
I am working my way through all the documentation on this, but help is needed.
Also, when showing your code PLEASE PASTE THE CODE here, as it’s easier to copy/modify it. Don’t post screenshots of the code, when you can just paste it here.
btw, clicking the routing symbol again shows the routing parameters as blank despite just being filled in.
Also, I have now pasted in your custom code to replace the generated code, this caused the anchor button link to go blank.
Anyway, the custom code advanced things, but I have noticed another, maybe, a problem.
The .htaccess has been overwritten by wappler (I have saved my original copy), and wappler has not restored the original .htaccess. Should that be expected?
This was true when the static downloads were finishing cleanly. The problem arises that it leaves the web site folders and files unsecure. Should I use FileCopy to restore the original .htaccess after download or is there a better way?
I am not sure i understand your question and what do you mean by "use FileCopy to restore the original .htaccess after download"
If there is an htaccess file in your local site directory, Wappler will just add its code below the existing content of your .htaccess file.
If there is no an .htaccess file in your local site folder, Wappler will create it and put its code inside. So in case your htaccess only exists on the server, it will be overwritten on upload ... so make sure your htaccess file exists in your local site folder.
Hi Teodore
The downloads are all working now.
I combined the 2 .htaccess files above with the wappler code appended after the original code.
Options -indexes
Options -MultiViews
RewriteRule .files. / [NC,F]
<FilesMatch “^php5?.(ini|cgi)$”>
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_METHOD} GET
RewriteRule ^/?api/apiUsers/File_Upload–uAttachment/([^/]+?)/([^/]+?)/([^/]+?)/([^/]+?)(?:/)?$ dmxConnect/api/apiUsers/File_Upload–uAttachment.php?filename=$1&folder1=$2&folder2=$3&folder3=$4 [QSA,NC,L]
End Wappler routing
I tested a download and I got a 403 forbidden, it would seem that the wappler code does not override the original code. But on the other hand the htaccess was preserved.
Hi Teodor
I have managed to solve the security issues with .htaccess (I believe so anyway- time will tell), now files can only be managed from within the web app and cannot be accessed directly on the web site.
Now I wish to tackle the issue of URL disguising.
On my file upload page, when I hover over the download icon, the full path to the underlying file is revealed.
I wish to disguise the yellow bits in the above image. I have tried a few ideas but nothing I have tried has worked so far. The tutorials on routing concentrate on improving SEO by disguising a parameter name and emphasizing a parameter value in a URL. This situation is different.
Do you have any hints of how to convert the url to something like…