Below is my fileupload script..
problem : When i run it on my server (localhost) with folder name c:\articles it works perfectly. Now i want to upload it to server of
www.tushar.com and want to store the files in
http://www.tushar.com/articles folder. When i type above path in Mypath="http://www.tushar.com/articles" it wont work..
Even though i hv created the folder article on server...
What path shud i write to make it work..
Plz help me
<%@ Page Language="
vb" %>
<html>
<Script Language="
VB" RunAt="Server">
Sub Page_Load(Sender as Object, e as EventArgs)
Dim MyPath, MyName as string
' Display the names in C:\ that represent directories.
MyPath = "C:\article" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
if MyName="" ' The folder is not there & to be created
MkDir("c:\article\") 'Folder created
span2.InnerHtml="A Folder (c:\article) is created at the Page_Load"
end if
End Sub
Sub Upload_Click(Sender as Object, e as EventArgs)
' Display properties of the uploaded file
FileName.InnerHtml = MyFile.PostedFile.FileName
FileContent.InnerHtml = MyFile.PostedFile.ContentType
FileSize.InnerHtml = MyFile.PostedFile.ContentLength
UploadDetails.visible = True
' Let us recover only the file name from its fully qualified path at client
Dim strFileName as string
strFileName = MyFile.PostedFile.FileName
Dim c as string = System.IO.Path.GetFileName(strFileName) ' only the attched file name not its path
' Let us Save uploaded file to server at C:\ServerFolder
Try
MyFile.PostedFile.SaveAs("c:\article" + c)
Span1.InnerHtml = "Your File Uploaded Sucessfully at server " & c
catch Exp as exception
span1.InnerHtml = "An Error occured. Please check the attached file"
UploadDetails.visible = false
span2.visible=false
End Try
End Sub
</Script>
<Body>
<B>Uploading In ASP.Net - A Rich
Uploading !
<P>
<Form Method="Post" EncType="Multipart/Form-Data" RunAt="Server">
Choose Your File To Upload :
<BR>
<Input ID="MyFile" Type="File" RunAt="Server" Size="40">
<BR>
<BR>
<Input Type="Submit" Value="Upload" OnServerclick="Upload_Click" RunAt="Server">
<P>
<Div ID="UploadDetails" Visible="False" RunAt="Server">
File Name:
<Span ID="FileName" RunAt="Server" />
<BR>
File Content:
<Span ID="FileContent" RunAt="Server" />
<BR>
File Size:
<Span ID="FileSize" RunAt="Server" />bytes
<BR>
</Div>
<Span ID="Span1" Style="Color:Red" RunAt="Server" />
<Span ID="Span2" Style="Color:Red" RunAt="Server" />
</Form>
</Body>
</html>