user3841709
user3841709

Reputation: 386

write data to local text file from live site

My question isn't necessarily how to write to a text file but, once my website is on the web hosts server, will the data still be written to the text file on my computer. I am currently working in Visual Web Developer and I am debugging in my machines localhost server. So right now there is no question that it will be written to the file on my computer but, once the site is live on another server and a different computer goes to the site, is it going to try to write to their computer?

Here is my code, I am simply looking for a little information and whether my code will need to change when I upload to a different server. I am trying to write paypal transaction details to a text file on my computer. Whenever someone purchases something from my website I need to get the data. It needs to be written in the text file that is on my computer and my computer only, not the actual user who purchased something.

Is this possible or am I going about this the wrong way and need to do something different?

Dim objfirst As New StreamWriter("C:\Users\User\Desktop\Sales Orders.txt", True)
For i As Integer = 1 To results("num_cart_items")
    objfirst.Write(results("first_name") + " " + results("last_name") + ", ")
    objfirst.Write(results("business").Replace("+", " ") & ", "
    objfirst.Write(results("address_street").Replace("+", " ") & ", " & results("address_city").Replace("+", " ") & ", " & results("address_state").Replace("+", " ") & ", " & results("address_zip") + ", ")

    objfirst.Write(results("payer_email").Replace("%40", "@") & ", ")
    objfirst.Write(results("item_name" & i).Replace("+", " ") + ", ")
    objfirst.Write(results("item_number" & i).Replace("+", "") + ", ")
    objfirst.Write(results("quantity" & i) + ", ")
    objfirst.Write(results("mc_gross_" & i))
    objfirst.WriteLine()

Upvotes: 2

Views: 1095

Answers (1)

Andrew Barber
Andrew Barber

Reputation: 40149

The code in question saves the file to the web server it's running on. It's saving on your computer now because your computer is the web server.

When you move the code to a 'real' web server, that's where the files will be saved, instead, with that code. They will not be saved to your personal computer, or any user's computer. Only on the server itself.


If you need the files to be 'sent' to you, you will need to look into a way to do that. EMail, a database, or a private area of the site where you can browse and view the files are your options. (more info on those is beyond the scope of things here)

One additional detail I have to mention: You need to make very sure that public users will have no access to the uploaded files. If you are running on a server with ASP.NET (including MVC), the App_Data folder is a good place, since by default, web requests cannot be made for files there. You'd then create code to view them separately. (Again; details on this are beyond the scope of this)

Upvotes: 1

Related Questions