PDA

View Full Version : ASP.net upload no working



lang79james
05-28-2009, 05:14 PM
Ok few months back I switch to linux on my server and using a virtual machine running server 2003 nothing really different then before other then the software to make it happen.

So the change I did make was I had to reinstall the server 2003 for the VM server hosting my site because the software I was using was not working with the saved hard drive file.

I thought everything was working just fine till today...... My file upload file coding is not working anymore

The computer name of my server is Webserver and the web root files are c:\Inetpub\wwwroot\ and I am linking the upload to a folder called files

when I run the upload page it says the file is not uploaded with the error message I give it. I have check the permission and security settings and they seem to be in order for the most....

Now for the coding of the page
files.aspx what people see
:
<%@LANGUAGE="VBSCRIPT"%><head runat="server"><title>Files</title>

<style type="text/css">

<!--

.style1 {font-size: xx-large}

-->

</style>

</head>

<%@ Import Namespace="System.IO" %>

<script language="VB" runat="server">

Sub Page_Load(sender as Object, e as EventArgs)

Dim dirInfo as New DirectoryInfo(Server.MapPath("\files"))



articleList.DataSource = dirInfo.GetFiles("*.*")

articleList.DataBind()

End Sub

</script>



<html>





<style type="text/css">

<!--

body,td,th {

font-family: Georgia, Times New Roman, Times, serif;

color: #CC0000;

}

body {

background-color: #000000;

}

-->

</style>

<body>

<center>

<table width="902" border="1" cellspacing="0" cellpadding="0">

<tr>

<th width="142" scope="col"><img src="/Images/dragon_3.gif" name="graphics1" align=BOTTOM width=142 height=248 border=0></th>

<th colspan="2" scope="col"><p align=CENTER class="style1">Files</p>

<!--#include file="header.aspx"-->

<br>

<br></th>

</tr>

<tr>

<th rowspan="3" valign="top" scope="row"><!--#include file="menu.aspx"--></th>

<td colspan="2"><p>

<p align="center"><asp:DataGrid runat="server" ID="articleList" Font-Name="Verdana"

AutoGenerateColumns="False" AlternatingItemStyle-BackColor="#eeeeee"

HeaderStyle-BackColor="Navy" HeaderStyle-ForeColor="White"

HeaderStyle-Font-Size="15pt" HeaderStyle-Font-Bold="True">

<columns>

<asp:HyperLinkColumn DataNavigateUrlField="Name" Target="_blank" DataNavigateUrlFormatString="./files/{0}" DataTextField="Name"

headertext="File Name" />

<asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time"

ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" />

<asp:BoundColumn DataField="Length" HeaderText="File Size"

ItemStyle-HorizontalAlign="Right"

DataFormatString="{0:#,### bytes}" />

</columns>

</asp:DataGrid></p>

<!--#include file="Webupload.aspx"-->

</td>

</tr>

<tr>



</tr>

<tr>

<td colspan="2" valign="top"><p align="left">

<!--#include file="~/footer.aspx"-->

</p>

</tr>

</table>

<p align="left">&nbsp;</p>

<p align="left">&nbsp;</p>





</center>

</body>

</html>


Back ground file:

<script language="VB" runat="server">



Sub Button1_Click(sender As Object, e As EventArgs)



if FileUpLoad1.HasFile

'Uncomment this line to Save the uploaded file

FileUpLoad1.SaveAs("c:\Inetpub\wwwroot\files\" & FileUpLoad1.Filename)

Label1.Text = "Received " & FileUpLoad1.FileName

else

Label1.Text = "No uploaded file"

end if



end sub



</script>





<h3 align="center"><font face="Verdana">Want to send me a file? </font></h3>



<p align="center"> If you send me a cool Picture I just might post it on one of my main pages.</p>



<div align="center">

<asp:FileUpLoad id="FileUpLoad1" AlternateText="You cannot upload files" runat="server" />





<asp:Button id="Button1" Text="Upload" OnClick="Button1_Click" runat="server" />

<asp:Label id="Label1" runat="server" />

</div>

</p>

lang79james
05-28-2009, 05:45 PM
ok it seems to be working it just can be an empty file has to have something in the text file i was testing