Uploading a file
1. Create your folder for uploads with the appropriate permissions
2. In form tag add this:
enctype="multipart/form-data"
3. And the input:
<input id="file1" type="file" name="file1" runat="server">
4. Add the submit
<input id="Submit1" type="submit" value="upload" runat="Server">
5. modify the submit code:
if not file1.postedfile is nothing and file1.postedfile.contentlength > 0 then
dim fn as string = (file1.postedfile.filename)
dim savelocation as string = Server.MapPath("foldername") & "\" & fn
try
file1.postedfile.saveas(savelocation)
response.write("The file has been uploaded.")
Catch exc as exception
response.write("Error: " & exc.message)
end try
else
response.write("Please select a file to upload")
enf if
2. In form tag add this:
enctype="multipart/form-data"
3. And the input:
<input id="file1" type="file" name="file1" runat="server">
4. Add the submit
<input id="Submit1" type="submit" value="upload" runat="Server">
5. modify the submit code:
if not file1.postedfile is nothing and file1.postedfile.contentlength > 0 then
dim fn as string = (file1.postedfile.filename)
dim savelocation as string = Server.MapPath("foldername") & "\" & fn
try
file1.postedfile.saveas(savelocation)
response.write("The file has been uploaded.")
Catch exc as exception
response.write("Error: " & exc.message)
end try
else
response.write("Please select a file to upload")
enf if
0 Comments:
Post a Comment
<< Home