|
-
Dec 5th, 2002, 03:08 PM
#1
Thread Starter
Frenzied Member
Error Uploading file to Server [RESOLVED]
Anyone know why I'm getting this error when I try to upload?
"Object reference not set to an instance of an object."
<input id="pdfUpload"
<FORM id="_ctl0" encType="multipart/form-data" runat="server">
If Not pdfUpload.PostedFile Is Nothing Then
If pdfUpload.PostedFile.FileName.Trim().Length > 0 And _
pdfUpload.PostedFile.ContentLength > 0 Then
Const strBaseDir As String = "C:\PBSS_Uploads\"
Dim strFilename As String = _
Path.GetFileName(pdfUpload.PostedFile.FileName)
pdfUpload.PostedFile.SaveAs(strBaseDir & strFilename)
End If
End If
Last edited by EyeTalion; Dec 9th, 2002 at 10:00 AM.
-
Dec 5th, 2002, 04:12 PM
#2
Could you attach the entire source for the upload component including the ASPX part?
Thanks
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Dec 6th, 2002, 08:32 AM
#3
Thread Starter
Frenzied Member
<body MS_POSITIONING="GridLayout">
<FORM id="_ctl0" name="_ctl0" encType="multipart/form-data" runat="server">
<input id="pdfUpload" style="Z-INDEX: 146; LEFT: 177px; WIDTH: 319px; POSITION: absolute; TOP: 339px; HEIGHT: 20px" type="file" size="34">
'PDF Upload
If Not pdfUpload.PostedFile Is Nothing Then
If pdfUpload.PostedFile.FileName.Trim().Length > 0 And _
pdfUpload.PostedFile.ContentLength > 0 Then
Const strBaseDir As String = "C:\PBSS_Uploads\"
Dim strFilename As String = _
Path.GetFileName(pdfUpload.PostedFile.FileName)
pdfUpload.PostedFile.SaveAs(strBaseDir & strFilename)
End If
End If
-
Dec 6th, 2002, 10:08 AM
#4
Thread Starter
Frenzied Member
I created another asp.net project and I only placed a button and <input> tag on the page. I still get the same error.
"Object reference not set to an instance of an object."
Here's the entire program:
Code:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="fileUpload.WebForm1"%>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<Script language="vb" runat="server">
Sub UploadTime(sender as object, e as eventArgs)
'PDF Upload
If Not pdfUpload.PostedFile Is Nothing Then
If pdfUpload.PostedFile.FileName.Trim().Length > 0 And _
pdfUpload.PostedFile.ContentLength > 0 Then
Const strBaseDir As String = "C:\PBSS_Uploads\"
Dim strFilename As String = _
Path.GetFileName(pdfUpload.PostedFile.FileName)
pdfUpload.PostedFile.SaveAs(strBaseDir & strFilename)
End If
End If
End Sub
</Script>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server" enctype="multipart/form-data">
<asp:Button id="Button1" OnClick="uploadtime" style="Z-INDEX: 101; LEFT: 105px; POSITION: absolute; TOP: 337px" runat="server" Text="Button" Width="101px" Height="40px"></asp:Button>
<INPUT id="pdfUpload" style="Z-INDEX: 102; LEFT: 49px; WIDTH: 350px; POSITION: absolute; TOP: 281px; HEIGHT: 23px" type="file" size="39">
</form>
</body>
</HTML>
-
Dec 6th, 2002, 01:57 PM
#5
Looks like your input box needs runat="server" (the pdfUpload box)
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Dec 9th, 2002, 10:00 AM
#6
Thread Starter
Frenzied Member
thanks rat, that was it.
Do you know how to filter out the common dialog box, so only .pdf extensions show?
-
Dec 9th, 2002, 03:31 PM
#7
Thread Starter
Frenzied Member
let me rephrase this, can you filter out file entensions in ASP.NET like you can in VB?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|