What do you mean by "send" - it serves HTML alright? But it doesn't serve other file formats? What is different about those other files compared to the HTML files? Both should be files on the server's file system, no? Are they treated differently by the server? Remember that images are binary files, so the server mustn't treat them as text.

Jacob Emantsal

Greenhorn

Posts: 4

posted 7 months ago

Tim Moores wrote:What do you mean by "send" - it serves HTML alright? But it doesn't serve other file formats? What is different about those other files compared to the HTML files? Both should be files on the server's file system, no? Are they treated differently by the server? Remember that images are binary files, so the server mustn't treat them as text.

Well, I dont really try to send send them, what happens is that the path you enter in the browser is that path it looks for. And I know works with the normal files, but maybe I am doing something wrong, here is my entire class.

Tim Moores

Saloon Keeper

Posts: 5287

143

posted 7 months ago

What you're doing in lines 28 to 34 is indeed treating the file as text - that works for HTML (and CSS and JS), but not for anything else like images. You need to replace that by code that streams the bytes (not characters) that make up the file to the client.

Tim Moores wrote:What you're doing in lines 28 to 34 is indeed treating the file as text - that works for HTML (and CSS and JS), but not for anything else like images. You need to replace that by code that streams the bytes (not characters) that make up the file to the client.