Change the PathShared constant to the directory you want to share, then change the LocalPort for the winsock control to the port you want the web-server to listen on
The path that you are sharing, should have some html files.
If for example you have an html file named Index.html, then in your browser just type "http://localhost/Index.html", and then you'll see that file in the browser...
I did not make it list files in the directory, so you need to know the file names in that directory when you want to download a file from the web-server...
Last edited by CVMichael; Mar 28th, 2003 at 04:47 AM.
Open the code and in the General Declaration section change the Private Const PathShared As String to whatever folder you want to put your html files in. Then in the Form_Load event change the Sck(0).LocalPort = line to: Sck(0).LocalPort = 80. Next open a browser and type: http:\\localhost\ and a file name that you put in the folder (i.e index.htm).
Note: The default port is 8080 so if you just changed the PathShared you should connect to http://YOUR_IP:8080/
Also I've seen there's no default file, you should probably correct this by hand. I inserted a line to make it working in most cases:
VB Code:
If RequestedFile = "/" Then: RequestedFile = "/index.html"
It's a pretty nice server but before using it in your projects you should spend some time with implementing stats and security functions. For example you should prevent the server from overwhelming / DoS attacks and such.
Fox, There is ALWAYS something to add to a web-server, and trust me I know how to make one, if you look at my web-page you'll see I have a complete web-server [Edit]Website not in use anymore[/Edit] (click on "My Programs" a ~6700 line web-server)
The purpose for this one is to make the beginners understand how to even start to make one, that's why I've made it in as few lines as possible so a beginner will not get confused.
And about the stats and security... unless you implement a log for the server, I don't see how it would serve for anything... if there are requests for the cmd.exe (or something like that) it will just send a 404 error, and if the file IS there (in the share) then it will send the actual file instead of executing it... so why worry ?
Last edited by CVMichael; Mar 26th, 2006 at 12:38 AM.
I don't know how to make an FTP server, I tried a long time ago, and I gave up, never tried since then... I did not need to... but if you just want to upload files onto a server, you can do it with an http server too... and obviously you can download with it also... The server I posted does not work if you try to upload, you will have to make some modifications to make it work for upload.
And hoanghiep, you are not supposed to ASK questions here, you do that in any other forum but this one... in this forum you only post code, and when you DO ask a question it should be about that particular code that was posted when starting the thread... in this case about the http server I posted...
hey at least be thankful for the guy for showing us the code. if you really want to get good with programming then you should be able to analyzee and be able to figure out what the syntax or the procedure is supposed to do. i am downloading the piece and will try to analyse the code and understand it before asking any questions.
dude, the starter of this subject "CVMicheal" or w/e, well your server doesnt display images and i dont know how to get it to work, and i dont like dreamvb's because i cannot get it in the systray for ****
Ah, I hate when people post to my old threads, because for some reason when they updated the vbforums, they did not mark old threads as subscribed... and I did not know that someone posted in the thread until now because I wanted to see what's new in the CodeBank... and I see my thread on top.
Anyways...
dreamvb, Why didn't you make your own thread ?
cokes, it should work with images, what kind of images are they, are they jpeg ?
Let me test and make sure...
I put the test_picture.jpg in the same directory as the html file
Changed the PathShared variable to where I put the html file and the jpg file, and then opened the web-page in the browser: http://localhost:8080/test.html
And it worked, it showed the picture just fine....
O I thought the project may have been of ome use to other people in the thread, saves them seraching around plus I thought it may have been some use to your self, But I was wrong. Anyway I now removed the thread and upload in my own sometime.
anyway Hope I never upset anyone.
When your dreams come true.
On error resume pulling hair out.