N
Neo Geshel
I am doing something wrong, but I cannot tell what. Either the web
browser is failing to upload the file, or the script is failing to catch
it. Either way, PostedFile is ending up empty.
First of all, I must specify a few things.
EVERYTHING IS SET UP IN THE CODE-BEHIND. THAT INCLUDES WRITING OUT ALL
OF THE HTML, AND ALL OF THE PAGE ELEMENTS. THERE IS NOTHING WHATSOEVER
IS THE WEB PAGE ITSELF, ASIDE FROM THE LINK TO THE CODE-BEHIND .VB FILE.
ALSO, CODE IS ONLY SNIPPETS; IT IS NOT THE COMPLETE SCRIPT. THE COMPLETE
SCRIPT RUNS AT OVER 3600 LINES, I DOUBT YOU WANT TO SEE THAT HERE. SO
DON'T BITCH THAT MY CODE IS NOT "COMPLETE", AS IT ACTUALLY IS, I'M JUST
LEAVING OUT REDUNDANT CODE.
Sorry for the shouting text, but some people just won't read the
details, and get bent out of shape when I have to repeat myself.
I have set up the form as follows:
myForm.ID = "myForm"
myForm.EncType = "multipart/form-data"
Controls.Add(myForm)
inputfile.id = "ImageUpload"
inputfile.Accept = "image/jpg"
myForm.Controls.Add(inputfile)
when I submit a fully-filled out form, other form elements (such as
textareas and input fields) can be easily recovered using
"inputfield.value", but using "inputfile.PostedFile" doesn't get me
anything back. That is, it is completely empty. When I try to get its
contents written out
ltrlPreview.Text = inputfile.PostedFile.ContentLength
I get "0"
When I use
ltrlPreview.Text = inputfile.PostedFile.ToString()
I get "System.Web.HttpPostedFile"
When I try "ImageUpload.PostedFile.ToString()" instead, the script
claims that ImageUpload has not been defined (even though it's clearly
used as the ID for the inputfile element). When I add:
Protected WithEvents ImageUpload As System.Web.UI.HtmlControls.HtmlInputFile
to appease the script (which doesn't make sense, since I don't have any
raw HTML, everything is created in the code-behind, so this shouldn't
have to be implemented) I get:
Object reference not set to an instance of an object.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
TeamMetz.Add30_Preview(Object sender, EventArgs e) +395
System.Web.UI.HtmlControls.HtmlInputButton.OnServerClick(EventArgs
e) +108
System.Web.UI.HtmlControls.HtmlInputButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
(In fact, when trying about a dozen other methods to retrieve the
contents of the uploaded file, the same error occurs. WHY??? What the
*fucking hell* does this error really mean?? Everything on the 'Net
about this error seems to make use of doublespeak, smoke & mirrors and
20-syllable tech words that are probably only found in PhD dissertions)
The really strange thing is that every other form field element can be
easily retrieved by calling its .value content. That is, if I add a text
field using:
inputtext.id = "Name"
inputtext.MaxLength = 50
myForm.Controls.Add(inputtext)
all I have to use to access the value I put in the field is:
inputtext.value
I don't even have to do a Request.Form("Name") to access it (unless I
have used more than one inputtext in a form). However, the inputfile
field seems to have resisted all attempts to retrieve data from it. I
select a proper file, attempt to upload it, and *poof*; nothing happens.
Nothing *appears* to have been uploaded, because inputfile.PostedFile is
empty.
Any help whatsoever would be greatly appreciated.
TIA,
...Geshel
--
***********************************************************************
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
***********************************************************************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.†*
* - Stephen F. Roberts *
***********************************************************************
* “Anyone who believes in Intelligent Design (“creationismâ€) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.†- 99.99+% of Scientists *
***********************************************************************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.†Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
***********************************************************************
browser is failing to upload the file, or the script is failing to catch
it. Either way, PostedFile is ending up empty.
First of all, I must specify a few things.
EVERYTHING IS SET UP IN THE CODE-BEHIND. THAT INCLUDES WRITING OUT ALL
OF THE HTML, AND ALL OF THE PAGE ELEMENTS. THERE IS NOTHING WHATSOEVER
IS THE WEB PAGE ITSELF, ASIDE FROM THE LINK TO THE CODE-BEHIND .VB FILE.
ALSO, CODE IS ONLY SNIPPETS; IT IS NOT THE COMPLETE SCRIPT. THE COMPLETE
SCRIPT RUNS AT OVER 3600 LINES, I DOUBT YOU WANT TO SEE THAT HERE. SO
DON'T BITCH THAT MY CODE IS NOT "COMPLETE", AS IT ACTUALLY IS, I'M JUST
LEAVING OUT REDUNDANT CODE.
Sorry for the shouting text, but some people just won't read the
details, and get bent out of shape when I have to repeat myself.
I have set up the form as follows:
myForm.ID = "myForm"
myForm.EncType = "multipart/form-data"
Controls.Add(myForm)
inputfile.id = "ImageUpload"
inputfile.Accept = "image/jpg"
myForm.Controls.Add(inputfile)
when I submit a fully-filled out form, other form elements (such as
textareas and input fields) can be easily recovered using
"inputfield.value", but using "inputfile.PostedFile" doesn't get me
anything back. That is, it is completely empty. When I try to get its
contents written out
ltrlPreview.Text = inputfile.PostedFile.ContentLength
I get "0"
When I use
ltrlPreview.Text = inputfile.PostedFile.ToString()
I get "System.Web.HttpPostedFile"
When I try "ImageUpload.PostedFile.ToString()" instead, the script
claims that ImageUpload has not been defined (even though it's clearly
used as the ID for the inputfile element). When I add:
Protected WithEvents ImageUpload As System.Web.UI.HtmlControls.HtmlInputFile
to appease the script (which doesn't make sense, since I don't have any
raw HTML, everything is created in the code-behind, so this shouldn't
have to be implemented) I get:
Object reference not set to an instance of an object.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
TeamMetz.Add30_Preview(Object sender, EventArgs e) +395
System.Web.UI.HtmlControls.HtmlInputButton.OnServerClick(EventArgs
e) +108
System.Web.UI.HtmlControls.HtmlInputButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
(In fact, when trying about a dozen other methods to retrieve the
contents of the uploaded file, the same error occurs. WHY??? What the
*fucking hell* does this error really mean?? Everything on the 'Net
about this error seems to make use of doublespeak, smoke & mirrors and
20-syllable tech words that are probably only found in PhD dissertions)
The really strange thing is that every other form field element can be
easily retrieved by calling its .value content. That is, if I add a text
field using:
inputtext.id = "Name"
inputtext.MaxLength = 50
myForm.Controls.Add(inputtext)
all I have to use to access the value I put in the field is:
inputtext.value
I don't even have to do a Request.Form("Name") to access it (unless I
have used more than one inputtext in a form). However, the inputfile
field seems to have resisted all attempts to retrieve data from it. I
select a proper file, attempt to upload it, and *poof*; nothing happens.
Nothing *appears* to have been uploaded, because inputfile.PostedFile is
empty.
Any help whatsoever would be greatly appreciated.
TIA,
...Geshel
--
***********************************************************************
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
***********************************************************************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.†*
* - Stephen F. Roberts *
***********************************************************************
* “Anyone who believes in Intelligent Design (“creationismâ€) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.†- 99.99+% of Scientists *
***********************************************************************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.†Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
***********************************************************************