Document Root in Debug

I am adding a file download function and I am trying to figure out where to put a test file when debugging (on a Mac if that makes a difference).

I assumed it was in the .debug directory but it is not found (404 error) when I do this:

http://127.0.0.1:8080/Test.pdf

[quote=135965:@Mark Strickland]I am adding a file download function and I am trying to figure out where to put a test file when debugging (on a Mac if that makes a difference).

I assumed it was in the .debug directory but it is not found (404 error) when I do this:

http://127.0.0.1:8080/Test.pdf [/quote]

Use a WebFile. See the Web/Downloading example project.

Using a WebFile would mean i need to fetch the file from the server and put it into a WebFile then use the code in the example to download it. That would work but I just want to use a simple link and open in a new page. The browser and user will decide to display it or download it.

I just want to use a WebLink and point it to the file. On my production server the document root is in httdocs and my files will be in a sub-directory off of that directory. For debug I need to figure out where to put the file.

I suppose that the WebServer used in debug is not capable of downloading a file with a WebLink.

WebLink.URL = "//http:127.0.0.1:8080/Test.pdf"
WebLink.Text = "Click Here to Download"

Then the user would click the link on the WebPage.

[quote=135968:@Mark Strickland]Using a WebFile would mean i need to fetch the file from the server and put it into a WebFile then use the code in the example to download it. That would work but I just want to use a simple link and open in a new page. The browser and user will decide to display it or download it.

I just want to use a WebLink and point it to the file. On my production server the document root is in httdocs and my files will be in a sub-directory off of that directory. For debug I need to figure out where to put the file.

I suppose that the WebServer used in debug is not capable of downloading a file with a WebLink.

WebLink.URL = "//http:127.0.0.1:8080/Test.pdf"
WebLink.Text = "Click Here to Download"

Then the user would click the link on the WebPage.[/quote]

The debug app is a standalone and it does not provide a web space. The only way you can have a path relative to your debug app is through a webfile.

If you want to test your app like it will behave on the host, just put your Test.pdf on your server in the right place and use that URL.

Yep — I just did that and it worked as expected.

Thanks.

Just for the record, I forgot the App.HandleSpecialURL event which permits you to serve files that are requested in the form of

http://127.0.0.1:8080/specialurl/Test.html or http://127.0.0.1:8080/api/Test.html

In such event you compare Request.Path to the name of the file, then send it through Request.Print to the client. You can manage an entire directory structure through that event, including pictures.

So what you wanted to do can be achieved that way. It is not as simple as uploading the files to a web space, but it works.

Well after being lazy and wanting to just use the WebLink I am now going to change my mind in favor of security. The downside on using a WebLink to download a file is the URL to the file is fully visible. It is not that I need lots of security but I am sure somebody with time on their hands would start to play with the URL and give me some negative results.

Back to the WebFile solution.