nickjf89 Posted August 10, 2011 Posted August 10, 2011 hi all i want to simply have some code that uploads some text onto my web server in a txt file in a directory like the example below: http://www.domain.co.uk/filegoeshere/file.txt i've found some solutions on the internet, but none that seem to work for me.. thanks Quote
Administrators PlausiblyDamp Posted August 10, 2011 Administrators Posted August 10, 2011 Could you post the code here rather than as a link, especially as a link that doesn't seem to work. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
nickjf89 Posted August 11, 2011 Author Posted August 11, 2011 that link was an example of where i'd like to upload it...thats not my actual website! the code i've been trying to make work is: Dim url As String = "http://www.callistocreations.co.uk/licensing/keys/file.txt" 'Dim file As String = "C:\Users\Nick\Desktop\Callisto Creations\Licensing\Unused Keys\" & keyText.Text & ".txt" 'My.Computer.Network.UploadFile(file, url) Quote
Administrators PlausiblyDamp Posted August 12, 2011 Administrators Posted August 12, 2011 If you try the code you posted above (without the last two lines commented out) what happens? Doe you get any specific errors raised or does it fail in some other way? Do you actually have permissions to upload to the specific area on the destination server? If so you will need to pass the appropriate credentials along with your request. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
nickjf89 Posted August 12, 2011 Author Posted August 12, 2011 I get a 404 error. I have 7,7,7 permissions so it should be fine. Quote
Administrators PlausiblyDamp Posted August 12, 2011 Administrators Posted August 12, 2011 Does the folder you are uploading to exist? Just because you have access to the file system doesn't mean the server is also configured to allow uploads though. What type of web server is it and how is security configured on the server? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
nickjf89 Posted August 12, 2011 Author Posted August 12, 2011 Yeah the folder exists. It's a linux-based shared web server. Any idea how to check if it allows uploads? Thanks Quote
Administrators PlausiblyDamp Posted August 12, 2011 Administrators Posted August 12, 2011 Do you know what the server is (e.g. Apache?) or id this is hosted externally would the hosting provider be able to supply this information. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
nickjf89 Posted August 12, 2011 Author Posted August 12, 2011 yes i believe it's apache. the code works fine, but the try catch always returns a 404 NOT FOUND error. what exactly can it not find...? Quote
Administrators PlausiblyDamp Posted August 12, 2011 Administrators Posted August 12, 2011 Do you need to log into the site before you are allowed to upload files? If so you need to pass your login credentials with the upload request. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
nickjf89 Posted August 12, 2011 Author Posted August 12, 2011 i have also tried this code with password and username...no luck Quote
Administrators PlausiblyDamp Posted August 12, 2011 Administrators Posted August 12, 2011 How did you pass in the username and password? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
nickjf89 Posted August 12, 2011 Author Posted August 12, 2011 Try My.Computer.Network.UploadFile("C:\Users\Nick\Desktop\Callisto Creations\Licensing\Unused Keys\" & keyText.Text & ".txt", "http://www.callistocreations.co.uk/licensing/keys/test.txt", "username", "password", True, 1000) Catch b As Exception MessageBox.Show(b.Message) End Try Quote
Administrators PlausiblyDamp Posted August 12, 2011 Administrators Posted August 12, 2011 It looks as though it is attempting to take the file contents and pass them to the URL you are specifying. You are getting a 404 because it is expecting http://www.callistocreations.co.uk/licensing/keys/test.txt to exist on the server already. Have you tried uploading to a destination URL of http://www.callistocreations.co.uk/licensing/keys to see what happens? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
nickjf89 Posted August 15, 2011 Author Posted August 15, 2011 yeah, it gives me an error that says i need to define a file. Quote
Administrators PlausiblyDamp Posted August 15, 2011 Administrators Posted August 15, 2011 It looks like you will need a page or handler on the server to set as the destination url, this would then receive the uploaded file and would be responsible for saving it out the the actual physical location. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
nickjf89 Posted August 15, 2011 Author Posted August 15, 2011 how would i do that? make a page eg. /uploads.html ? then how would i read that? thanks Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.