|
-
Feb 2nd, 2018, 11:52 AM
#5
Re: [RESOLVED] Using Winsock To Send A Message To A Web Browser...
 Originally Posted by mcoulter876
What about sending a file back, like an image or a pre-generated .html file?
As I said in my post, I read in the contents of the file being requested and append those contents to the strOutData variable. So you need to define the "root" path of your web server (the local path on the web server where the website contents are stored), and you need to determine the path\filename that is being requested by the web server.
Once you have that you can build the path to the local file being requested, and then read in the contents of the file and append those contents to strOutData.
So, if you say that "C:\Inetpub\wwwroot\" is the local root path, and the user requests "http://www.yoursite.com/Subfolder/Index.html", you need code that will parse out the "Subfolder/Index.html" piece, and then the file that you serve up should come from "C:\Inetpub\wwwroot\Subfolder\Index.html"
Note that in my code, if the file is .htm/html, I am retrieving the data from the file by opening the file "For Input". For image or unknown file types, I'm opening the file "For Binary Access Read"
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|