473,698 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Uploading File w/o HtmlInputFile control

I have an application that uses FreeTextBox 2.0
(http://www.freetextbox.com). FreeTextBox is a rich text editor that behaves
similarly to MS Word. The FreeTextBox control has a button to insert images
(just as you would with MS Word) and it works beautifully. The problem is
that when you include an image with the rich text editor, the image path is
the local path on the client. I have written a method that examines the text
for <img> tags, extracts the local path, and then replaces it with what the
virtual path will be after the file has been saved to the server.

I would like post the file to the server as I would with an HtmlInputFile
(PostedFile) control using the HttpPostedFile object, but it would appear
that this is not allowed. After doing some digging, it looks like my best
option would be to write a Web Service that accepts the image as a byte
array and use the WebClient object to upload the file to the service.

It sounds like this would work but I don't really know how to approach this.
I would rather just straight post the file to the HttpPostedFileC ollection
just like an HtmlInputFile control does, but that doesn't look like a
possible option. If anyone knows a good means to upload a file without the
HtmlInputFile control, please let me know.

TIA,

Grant Harmeyer
Nov 18 '05 #1
5 3107
what do you mean the htmlinput file is not allowed ?
i have used that object with freetextbox. have a look at this

<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="3" width="700" border="0">
<tr>
<td><uc1:module title id="ModuleTitle 1" runat="server"
DisplayText="Em ail Users"></uc1:moduletitle ></td>
</tr>
<tr>
<td vAlign="top" align="left"><b >Mailer&nbsp;Su bject</b></td>
<td><asp:requir edfieldvalidato r id="RFVSubject " runat="server"
Display="Dynami c" ControlToValida te="txtSubject "
ErrorMessage="S ubject Required">*</asp:requiredfie ldvalidator></td>
</tr>
<tr>
<td colSpan="2"><as p:textbox id="txtSubject " runat="server"
MaxLength="100" Columns="50" Width="600px"></asp:textbox></td>
</tr>
<tr>
<td vAlign="top" align="left"><b >Mailer Body</b></td>
<td><asp:requir edfieldvalidato r id="RFVBody" runat="server"
Display="Dynami c" ControlToValida te="txtBody" ErrorMessage="I tem Text
Required">*</asp:requiredfie ldvalidator></td>
</tr>
<tr>
<td colSpan="2"><FT B:FREETEXTBOX id="txtBody" runat="server"
Width="600px" BreakMode="Line Break" DownLevelCols=" 50"

ToolbarLayout=" paragraphmenu,f ontsizesmenu,Fo ntForeColorsMen u,FontBackColor s
Menu|bold,itali c,underline,Str ikethrough, Superscript,
Subscript;Justi fyLeft, JustifyRight, JustifyCenter,
JustifyFull;bul letedlist,numbe redlist;CreateL ink, Unlink; Cut, Copy, Paste,
Undo, Redo"></FTB:FREETEXTBOX ></td>
</tr>
<tr>
<td colSpan="2"><b> Mailer&nbsp;Ima ge Navigation URL</b></td>
</tr>
<tr>
<td>
<asp:TextBox id="txtNavigate URL" runat="server" Width="600px"
Columns="50" MaxLength="200" ></asp:TextBox>
</td>
<td>
<asp:RegularExp ressionValidato r id="REVNavigate URL" runat="server"
ErrorMessage="I nvalid URL for Image Navigation"
ControlToValida te="txtNavigate URL" Display="Dynami c"
ValidationExpre ssion="http://([\w-]+\.)+[\w-]+(/[\w-
../?%&amp;=]*)?">*</asp:RegularExpr essionValidator ></td>
</tr>
<tr>
<td colSpan="2"><b> Mailer&nbsp;Ima ge</b></td>
</tr>
<tr>
<td colSpan="2">
<asp:Image id="imgMainImag e" runat="server"> </asp:Image></td>
</tr>
<tr>
<td colSpan="2"><IN PUT id="uploadMainI mage" style="WIDTH: 600px"
type="file" size="80" runat="server">
</td>
</tr>
<tr>
<td colSpan="2">&nb sp;</td>
</tr>
<tr>
<td colSpan="2"><as pzone:oneclickb utton id="btnSubmit" runat="server"
Text="Submit"></aspzone:oneclic kbutton>&nbsp;& nbsp;&nbsp;&nbs p;
<asp:button id="btnCancel" runat="server" Text="Cancel"
CausesValidatio n="False"></asp:button><asp :validationsumm ary
id="ValidationS ummary1" runat="server" HeaderText="Err ors!! Please correct
the following:"
ShowSummary="Fa lse" ShowMessageBox= "True"></asp:validations ummary>
</td>
</tr>
</table>
</form>

from code behind

if(Page.IsValid )
{
HttpFileCollect ion myFiles = Request.Files;
HttpPostedFile myFile = myFiles[0];

MailingListDB mlDB = new MailingListDB() ;
if((bool)ViewSt ate["isAdd"] == true)
{
mlDB.AddNewMail er(txtSubject.T ext.Trim(), txtBody.Text,
txtNavigateURL. Text.Trim(), ref myFile);
}
else
{
mlDB.UpdateExis tingMailer((int )ViewState["MailerID"],
txtSubject.Text .Trim(), txtBody.Text, txtNavigateURL. Text.Trim(), ref
myFile);
}

if(ViewState["URLReferre r"] != null)
{
Response.Redire ct(Convert.ToSt ring(ViewState["URLReferre r"]));
}
else
{
Response.Redire ct("~");
}
}

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Grant Harmeyer" <ne*@internetap ollo.com> wrote in message
news:eB******** ******@TK2MSFTN GP10.phx.gbl...
I have an application that uses FreeTextBox 2.0
(http://www.freetextbox.com). FreeTextBox is a rich text editor that behaves similarly to MS Word. The FreeTextBox control has a button to insert images (just as you would with MS Word) and it works beautifully. The problem is
that when you include an image with the rich text editor, the image path is the local path on the client. I have written a method that examines the text for <img> tags, extracts the local path, and then replaces it with what the virtual path will be after the file has been saved to the server.

I would like post the file to the server as I would with an HtmlInputFile
(PostedFile) control using the HttpPostedFile object, but it would appear
that this is not allowed. After doing some digging, it looks like my best
option would be to write a Web Service that accepts the image as a byte
array and use the WebClient object to upload the file to the service.

It sounds like this would work but I don't really know how to approach this. I would rather just straight post the file to the HttpPostedFileC ollection
just like an HtmlInputFile control does, but that doesn't look like a
possible option. If anyone knows a good means to upload a file without the
HtmlInputFile control, please let me know.

TIA,

Grant Harmeyer

Nov 18 '05 #2
Bad choice of wording on my part, I apologize. Yes the HtmlInputFile control
is allowed, but it doesn't make much sense to have an HtmlFileInput control
on the WebForm for the images that the FreeTextBox control inserts into the
"Text" property. The "Text" property of the FreeTextBox object may contain
several <img> tags, so a single HtmlInputFile control doesn't make much
sense, unless I want to limit users on the placement and number of images
that are allowed.

Again, I apologize if my wording from this post or the previous post seemed
confusing. Thanks for the help.

Grant

"Hermit Dave" <he************ @CAPS.AND.DOTS. hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
what do you mean the htmlinput file is not allowed ?
i have used that object with freetextbox. have a look at this

<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="3" width="700" border="0">
<tr>
<td><uc1:module title id="ModuleTitle 1" runat="server"
DisplayText="Em ail Users"></uc1:moduletitle ></td>
</tr>
<tr>
<td vAlign="top" align="left"><b >Mailer&nbsp;Su bject</b></td>
<td><asp:requir edfieldvalidato r id="RFVSubject " runat="server"
Display="Dynami c" ControlToValida te="txtSubject "
ErrorMessage="S ubject Required">*</asp:requiredfie ldvalidator></td>
</tr>
<tr>
<td colSpan="2"><as p:textbox id="txtSubject " runat="server"
MaxLength="100" Columns="50" Width="600px"></asp:textbox></td>
</tr>
<tr>
<td vAlign="top" align="left"><b >Mailer Body</b></td>
<td><asp:requir edfieldvalidato r id="RFVBody" runat="server"
Display="Dynami c" ControlToValida te="txtBody" ErrorMessage="I tem Text
Required">*</asp:requiredfie ldvalidator></td>
</tr>
<tr>
<td colSpan="2"><FT B:FREETEXTBOX id="txtBody" runat="server"
Width="600px" BreakMode="Line Break" DownLevelCols=" 50"

ToolbarLayout=" paragraphmenu,f ontsizesmenu,Fo ntForeColorsMen u,FontBackColor s
Menu|bold,itali c,underline,Str ikethrough, Superscript,
Subscript;Justi fyLeft, JustifyRight, JustifyCenter,
JustifyFull;bul letedlist,numbe redlist;CreateL ink, Unlink; Cut, Copy,
Paste,
Undo, Redo"></FTB:FREETEXTBOX ></td>
</tr>
<tr>
<td colSpan="2"><b> Mailer&nbsp;Ima ge Navigation URL</b></td>
</tr>
<tr>
<td>
<asp:TextBox id="txtNavigate URL" runat="server" Width="600px"
Columns="50" MaxLength="200" ></asp:TextBox>
</td>
<td>
<asp:RegularExp ressionValidato r id="REVNavigate URL" runat="server"
ErrorMessage="I nvalid URL for Image Navigation"
ControlToValida te="txtNavigate URL" Display="Dynami c"
ValidationExpre ssion="http://([\w-]+\.)+[\w-]+(/[\w-
./?%&amp;=]*)?">*</asp:RegularExpr essionValidator ></td>
</tr>
<tr>
<td colSpan="2"><b> Mailer&nbsp;Ima ge</b></td>
</tr>
<tr>
<td colSpan="2">
<asp:Image id="imgMainImag e" runat="server"> </asp:Image></td>
</tr>
<tr>
<td colSpan="2"><IN PUT id="uploadMainI mage" style="WIDTH: 600px"
type="file" size="80" runat="server">
</td>
</tr>
<tr>
<td colSpan="2">&nb sp;</td>
</tr>
<tr>
<td colSpan="2"><as pzone:oneclickb utton id="btnSubmit" runat="server"
Text="Submit"></aspzone:oneclic kbutton>&nbsp;& nbsp;&nbsp;&nbs p;
<asp:button id="btnCancel" runat="server" Text="Cancel"
CausesValidatio n="False"></asp:button><asp :validationsumm ary
id="ValidationS ummary1" runat="server" HeaderText="Err ors!! Please correct
the following:"
ShowSummary="Fa lse" ShowMessageBox= "True"></asp:validations ummary>
</td>
</tr>
</table>
</form>

from code behind

if(Page.IsValid )
{
HttpFileCollect ion myFiles = Request.Files;
HttpPostedFile myFile = myFiles[0];

MailingListDB mlDB = new MailingListDB() ;
if((bool)ViewSt ate["isAdd"] == true)
{
mlDB.AddNewMail er(txtSubject.T ext.Trim(), txtBody.Text,
txtNavigateURL. Text.Trim(), ref myFile);
}
else
{
mlDB.UpdateExis tingMailer((int )ViewState["MailerID"],
txtSubject.Text .Trim(), txtBody.Text, txtNavigateURL. Text.Trim(), ref
myFile);
}

if(ViewState["URLReferre r"] != null)
{
Response.Redire ct(Convert.ToSt ring(ViewState["URLReferre r"]));
}
else
{
Response.Redire ct("~");
}
}

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Grant Harmeyer" <ne*@internetap ollo.com> wrote in message
news:eB******** ******@TK2MSFTN GP10.phx.gbl...
I have an application that uses FreeTextBox 2.0
(http://www.freetextbox.com). FreeTextBox is a rich text editor that

behaves
similarly to MS Word. The FreeTextBox control has a button to insert

images
(just as you would with MS Word) and it works beautifully. The problem is
that when you include an image with the rich text editor, the image path

is
the local path on the client. I have written a method that examines the

text
for <img> tags, extracts the local path, and then replaces it with what

the
virtual path will be after the file has been saved to the server.

I would like post the file to the server as I would with an HtmlInputFile
(PostedFile) control using the HttpPostedFile object, but it would appear
that this is not allowed. After doing some digging, it looks like my best
option would be to write a Web Service that accepts the image as a byte
array and use the WebClient object to upload the file to the service.

It sounds like this would work but I don't really know how to approach

this.
I would rather just straight post the file to the
HttpPostedFileC ollection
just like an HtmlInputFile control does, but that doesn't look like a
possible option. If anyone knows a good means to upload a file without
the
HtmlInputFile control, please let me know.

TIA,

Grant Harmeyer


Nov 18 '05 #3
well i had a similar problem, the problem is that once on clients page.. the
code is static unless the user posts it.. and there's no way to determine
how many images the user's trying to upload

i would suggest is either limit the number of images or provide a seperate
page for images to uploaded.. ie the user adds the text with placeholders
and then uploads corresponding images seperately.. then you could replace
the placeholders with images at appropriate places.

hth

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Grant Harmeyer" <ne*@internetap ollo.com> wrote in message
news:uk******** ******@TK2MSFTN GP11.phx.gbl...
Bad choice of wording on my part, I apologize. Yes the HtmlInputFile control is allowed, but it doesn't make much sense to have an HtmlFileInput control on the WebForm for the images that the FreeTextBox control inserts into the "Text" property. The "Text" property of the FreeTextBox object may contain
several <img> tags, so a single HtmlInputFile control doesn't make much
sense, unless I want to limit users on the placement and number of images
that are allowed.

Again, I apologize if my wording from this post or the previous post seemed confusing. Thanks for the help.

Grant

"Hermit Dave" <he************ @CAPS.AND.DOTS. hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
what do you mean the htmlinput file is not allowed ?
i have used that object with freetextbox. have a look at this

<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="3" width="700" border="0">
<tr>
<td><uc1:module title id="ModuleTitle 1" runat="server"
DisplayText="Em ail Users"></uc1:moduletitle ></td>
</tr>
<tr>
<td vAlign="top" align="left"><b >Mailer&nbsp;Su bject</b></td>
<td><asp:requir edfieldvalidato r id="RFVSubject " runat="server"
Display="Dynami c" ControlToValida te="txtSubject "
ErrorMessage="S ubject Required">*</asp:requiredfie ldvalidator></td> </tr>
<tr>
<td colSpan="2"><as p:textbox id="txtSubject " runat="server"
MaxLength="100" Columns="50" Width="600px"></asp:textbox></td>
</tr>
<tr>
<td vAlign="top" align="left"><b >Mailer Body</b></td>
<td><asp:requir edfieldvalidato r id="RFVBody" runat="server"
Display="Dynami c" ControlToValida te="txtBody" ErrorMessage="I tem Text
Required">*</asp:requiredfie ldvalidator></td>
</tr>
<tr>
<td colSpan="2"><FT B:FREETEXTBOX id="txtBody" runat="server"
Width="600px" BreakMode="Line Break" DownLevelCols=" 50"

ToolbarLayout=" paragraphmenu,f ontsizesmenu,Fo ntForeColorsMen u,FontBackColor s Menu|bold,itali c,underline,Str ikethrough, Superscript,
Subscript;Justi fyLeft, JustifyRight, JustifyCenter,
JustifyFull;bul letedlist,numbe redlist;CreateL ink, Unlink; Cut, Copy,
Paste,
Undo, Redo"></FTB:FREETEXTBOX ></td>
</tr>
<tr>
<td colSpan="2"><b> Mailer&nbsp;Ima ge Navigation URL</b></td>
</tr>
<tr>
<td>
<asp:TextBox id="txtNavigate URL" runat="server" Width="600px"
Columns="50" MaxLength="200" ></asp:TextBox>
</td>
<td>
<asp:RegularExp ressionValidato r id="REVNavigate URL" runat="server"
ErrorMessage="I nvalid URL for Image Navigation"
ControlToValida te="txtNavigate URL" Display="Dynami c"
ValidationExpre ssion="http://([\w-]+\.)+[\w-]+(/[\w-
./?%&amp;=]*)?">*</asp:RegularExpr essionValidator ></td>
</tr>
<tr>
<td colSpan="2"><b> Mailer&nbsp;Ima ge</b></td>
</tr>
<tr>
<td colSpan="2">
<asp:Image id="imgMainImag e" runat="server"> </asp:Image></td>
</tr>
<tr>
<td colSpan="2"><IN PUT id="uploadMainI mage" style="WIDTH: 600px"
type="file" size="80" runat="server">
</td>
</tr>
<tr>
<td colSpan="2">&nb sp;</td>
</tr>
<tr>
<td colSpan="2"><as pzone:oneclickb utton id="btnSubmit" runat="server" Text="Submit"></aspzone:oneclic kbutton>&nbsp;& nbsp;&nbsp;&nbs p;
<asp:button id="btnCancel" runat="server" Text="Cancel"
CausesValidatio n="False"></asp:button><asp :validationsumm ary
id="ValidationS ummary1" runat="server" HeaderText="Err ors!! Please correct the following:"
ShowSummary="Fa lse" ShowMessageBox= "True"></asp:validations ummary>
</td>
</tr>
</table>
</form>

from code behind

if(Page.IsValid )
{
HttpFileCollect ion myFiles = Request.Files;
HttpPostedFile myFile = myFiles[0];

MailingListDB mlDB = new MailingListDB() ;
if((bool)ViewSt ate["isAdd"] == true)
{
mlDB.AddNewMail er(txtSubject.T ext.Trim(), txtBody.Text,
txtNavigateURL. Text.Trim(), ref myFile);
}
else
{
mlDB.UpdateExis tingMailer((int )ViewState["MailerID"],
txtSubject.Text .Trim(), txtBody.Text, txtNavigateURL. Text.Trim(), ref
myFile);
}

if(ViewState["URLReferre r"] != null)
{
Response.Redire ct(Convert.ToSt ring(ViewState["URLReferre r"]));
}
else
{
Response.Redire ct("~");
}
}

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Grant Harmeyer" <ne*@internetap ollo.com> wrote in message
news:eB******** ******@TK2MSFTN GP10.phx.gbl...
I have an application that uses FreeTextBox 2.0
(http://www.freetextbox.com). FreeTextBox is a rich text editor that

behaves
similarly to MS Word. The FreeTextBox control has a button to insert

images
(just as you would with MS Word) and it works beautifully. The problem is that when you include an image with the rich text editor, the image path
is
the local path on the client. I have written a method that examines the

text
for <img> tags, extracts the local path, and then replaces it with what

the
virtual path will be after the file has been saved to the server.

I would like post the file to the server as I would with an

HtmlInputFile (PostedFile) control using the HttpPostedFile object, but it would appear that this is not allowed. After doing some digging, it looks like my best option would be to write a Web Service that accepts the image as a byte
array and use the WebClient object to upload the file to the service.

It sounds like this would work but I don't really know how to approach

this.
I would rather just straight post the file to the
HttpPostedFileC ollection
just like an HtmlInputFile control does, but that doesn't look like a
possible option. If anyone knows a good means to upload a file without
the
HtmlInputFile control, please let me know.

TIA,

Grant Harmeyer



Nov 18 '05 #4
or once the user posts the data you could do a scan and redirect a form to
the user which auto submits on load. this for you can have all the parsed
images within htmlfileinput control.

give it a try.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Hermit Dave" <he************ @CAPS.AND.DOTS. hotmail.com> wrote in message
news:OZ******** ******@tk2msftn gp13.phx.gbl...
well i had a similar problem, the problem is that once on clients page..
the
code is static unless the user posts it.. and there's no way to determine
how many images the user's trying to upload

i would suggest is either limit the number of images or provide a seperate
page for images to uploaded.. ie the user adds the text with placeholders
and then uploads corresponding images seperately.. then you could replace
the placeholders with images at appropriate places.

hth

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Grant Harmeyer" <ne*@internetap ollo.com> wrote in message
news:uk******** ******@TK2MSFTN GP11.phx.gbl...
Bad choice of wording on my part, I apologize. Yes the HtmlInputFile

control
is allowed, but it doesn't make much sense to have an HtmlFileInput

control
on the WebForm for the images that the FreeTextBox control inserts into

the
"Text" property. The "Text" property of the FreeTextBox object may
contain
several <img> tags, so a single HtmlInputFile control doesn't make much
sense, unless I want to limit users on the placement and number of images
that are allowed.

Again, I apologize if my wording from this post or the previous post

seemed
confusing. Thanks for the help.

Grant

"Hermit Dave" <he************ @CAPS.AND.DOTS. hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
> what do you mean the htmlinput file is not allowed ?
> i have used that object with freetextbox. have a look at this
>
> <form id="Form1" method="post" runat="server">
> <table cellSpacing="0" cellPadding="3" width="700" border="0">
> <tr>
> <td><uc1:module title id="ModuleTitle 1" runat="server"
> DisplayText="Em ail Users"></uc1:moduletitle ></td>
> </tr>
> <tr>
> <td vAlign="top" align="left"><b >Mailer&nbsp;Su bject</b></td>
> <td><asp:requir edfieldvalidato r id="RFVSubject " runat="server"
> Display="Dynami c" ControlToValida te="txtSubject "
> ErrorMessage="S ubject Required">*</asp:requiredfie ldvalidator></td> > </tr>
> <tr>
> <td colSpan="2"><as p:textbox id="txtSubject " runat="server"
> MaxLength="100" Columns="50" Width="600px"></asp:textbox></td>
> </tr>
> <tr>
> <td vAlign="top" align="left"><b >Mailer Body</b></td>
> <td><asp:requir edfieldvalidato r id="RFVBody" runat="server"
> Display="Dynami c" ControlToValida te="txtBody" ErrorMessage="I tem Text
> Required">*</asp:requiredfie ldvalidator></td>
> </tr>
> <tr>
> <td colSpan="2"><FT B:FREETEXTBOX id="txtBody" runat="server"
> Width="600px" BreakMode="Line Break" DownLevelCols=" 50"
>
> ToolbarLayout=" paragraphmenu,f ontsizesmenu,Fo ntForeColorsMen u,FontBackColor s > Menu|bold,itali c,underline,Str ikethrough, Superscript,
> Subscript;Justi fyLeft, JustifyRight, JustifyCenter,
> JustifyFull;bul letedlist,numbe redlist;CreateL ink, Unlink; Cut, Copy,
> Paste,
> Undo, Redo"></FTB:FREETEXTBOX ></td>
> </tr>
> <tr>
> <td colSpan="2"><b> Mailer&nbsp;Ima ge Navigation URL</b></td>
> </tr>
> <tr>
> <td>
> <asp:TextBox id="txtNavigate URL" runat="server" Width="600px"
> Columns="50" MaxLength="200" ></asp:TextBox>
> </td>
> <td>
> <asp:RegularExp ressionValidato r id="REVNavigate URL" runat="server"
> ErrorMessage="I nvalid URL for Image Navigation"
> ControlToValida te="txtNavigate URL" Display="Dynami c"
> ValidationExpre ssion="http://([\w-]+\.)+[\w-]+(/[\w-
> ./?%&amp;=]*)?">*</asp:RegularExpr essionValidator ></td>
> </tr>
> <tr>
> <td colSpan="2"><b> Mailer&nbsp;Ima ge</b></td>
> </tr>
> <tr>
> <td colSpan="2">
> <asp:Image id="imgMainImag e" runat="server"> </asp:Image></td>
> </tr>
> <tr>
> <td colSpan="2"><IN PUT id="uploadMainI mage" style="WIDTH: 600px"
> type="file" size="80" runat="server">
> </td>
> </tr>
> <tr>
> <td colSpan="2">&nb sp;</td>
> </tr>
> <tr>
> <td colSpan="2"><as pzone:oneclickb utton id="btnSubmit" runat="server" > Text="Submit"></aspzone:oneclic kbutton>&nbsp;& nbsp;&nbsp;&nbs p;
> <asp:button id="btnCancel" runat="server" Text="Cancel"
> CausesValidatio n="False"></asp:button><asp :validationsumm ary
> id="ValidationS ummary1" runat="server" HeaderText="Err ors!! Please correct > the following:"
> ShowSummary="Fa lse"
> ShowMessageBox= "True"></asp:validations ummary>
> </td>
> </tr>
> </table>
> </form>
>
> from code behind
>
> if(Page.IsValid )
> {
> HttpFileCollect ion myFiles = Request.Files;
> HttpPostedFile myFile = myFiles[0];
>
> MailingListDB mlDB = new MailingListDB() ;
> if((bool)ViewSt ate["isAdd"] == true)
> {
> mlDB.AddNewMail er(txtSubject.T ext.Trim(), txtBody.Text,
> txtNavigateURL. Text.Trim(), ref myFile);
> }
> else
> {
> mlDB.UpdateExis tingMailer((int )ViewState["MailerID"],
> txtSubject.Text .Trim(), txtBody.Text, txtNavigateURL. Text.Trim(), ref
> myFile);
> }
>
> if(ViewState["URLReferre r"] != null)
> {
> Response.Redire ct(Convert.ToSt ring(ViewState["URLReferre r"]));
> }
> else
> {
> Response.Redire ct("~");
> }
> }
>
> --
>
> Regards,
>
> Hermit Dave
> (http://hdave.blogspot.com)
> "Grant Harmeyer" <ne*@internetap ollo.com> wrote in message
> news:eB******** ******@TK2MSFTN GP10.phx.gbl...
>> I have an application that uses FreeTextBox 2.0
>> (http://www.freetextbox.com). FreeTextBox is a rich text editor that
> behaves
>> similarly to MS Word. The FreeTextBox control has a button to insert
> images
>> (just as you would with MS Word) and it works beautifully. The problem is >> that when you include an image with the rich text editor, the image path > is
>> the local path on the client. I have written a method that examines
>> the
> text
>> for <img> tags, extracts the local path, and then replaces it with
>> what
> the
>> virtual path will be after the file has been saved to the server.
>>
>> I would like post the file to the server as I would with an HtmlInputFile >> (PostedFile) control using the HttpPostedFile object, but it would appear >> that this is not allowed. After doing some digging, it looks like my best >> option would be to write a Web Service that accepts the image as a
>> byte
>> array and use the WebClient object to upload the file to the service.
>>
>> It sounds like this would work but I don't really know how to approach
> this.
>> I would rather just straight post the file to the
>> HttpPostedFileC ollection
>> just like an HtmlInputFile control does, but that doesn't look like a
>> possible option. If anyone knows a good means to upload a file without
>> the
>> HtmlInputFile control, please let me know.
>>
>> TIA,
>>
>> Grant Harmeyer
>>
>>
>
>



Nov 18 '05 #5

I am trying to use the code suggested by dave. I use the
freetextbox control. Not able to get it working when I insert an image
in the freetextbox control.
The "request.fi les" Collection is empty inspite of an image being
inserted into the freetextbox.
Any ideas?

Thanks,
Sam.

Hermit Dave wrote:
what do you mean the htmlinput file is not allowed ?
i have used that object with freetextbox. have a look at this

<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="3" width="700" border="0">
<tr>
<td><uc1:module title id="ModuleTitle 1" runat="server"
DisplayText="Em ail Users"></uc1:moduletitle ></td>
</tr>
<tr>
<td vAlign="top" align="left"><b >Mailer&nbsp;Su bject</b></td>
<td><asp:requir edfieldvalidato r id="RFVSubject " runat="server"
Display="Dynami c" ControlToValida te="txtSubject "
ErrorMessage="S ubject Required">*</asp:requiredfie ldvalidator></td> </tr>
<tr>
<td colSpan="2"><as p:textbox id="txtSubject " runat="server"
MaxLength="100" Columns="50" Width="600px"></asp:textbox></td>
</tr>
<tr>
<td vAlign="top" align="left"><b >Mailer Body</b></td>
<td><asp:requir edfieldvalidato r id="RFVBody" runat="server"
Display="Dynami c" ControlToValida te="txtBody" ErrorMessage="I tem Text
Required">*</asp:requiredfie ldvalidator></td>
</tr>
<tr>
<td colSpan="2"><FT B:FREETEXTBOX id="txtBody" runat="server"
Width="600px" BreakMode="Line Break" DownLevelCols=" 50"

ToolbarLayout=" paragraphmenu,f ontsizesmenu,Fo ntForeColorsMen u,FontBackColor s Menu|bold,itali c,underline,Str ikethrough, Superscript,
Subscript;Justi fyLeft, JustifyRight, JustifyCenter,
JustifyFull;bul letedlist,numbe redlist;CreateL ink, Unlink; Cut, Copy, Paste, Undo, Redo"></FTB:FREETEXTBOX ></td>
</tr>
<tr>
<td colSpan="2"><b> Mailer&nbsp;Ima ge Navigation URL</b></td>
</tr>
<tr>
<td>
<asp:TextBox id="txtNavigate URL" runat="server" Width="600px"
Columns="50" MaxLength="200" ></asp:TextBox>
</td>
<td>
<asp:RegularExp ressionValidato r id="REVNavigate URL" runat="server" ErrorMessage="I nvalid URL for Image Navigation"
ControlToValida te="txtNavigate URL" Display="Dynami c"
ValidationExpre ssion="http://([\w-]+\.)+[\w-]+(/[\w-
./?%&amp;=]*)?">*</asp:RegularExpr essionValidator ></td>
</tr>
<tr>
<td colSpan="2"><b> Mailer&nbsp;Ima ge</b></td>
</tr>
<tr>
<td colSpan="2">
<asp:Image id="imgMainImag e" runat="server"> </asp:Image></td>
</tr>
<tr>
<td colSpan="2"><IN PUT id="uploadMainI mage" style="WIDTH: 600px"
type="file" size="80" runat="server">
</td>
</tr>
<tr>
<td colSpan="2">&nb sp;</td>
</tr>
<tr>
<td colSpan="2"><as pzone:oneclickb utton id="btnSubmit" runat="server" Text="Submit"></aspzone:oneclic kbutton>&nbsp;& nbsp;&nbsp;&nbs p;
<asp:button id="btnCancel" runat="server" Text="Cancel"
CausesValidatio n="False"></asp:button><asp :validationsumm ary
id="ValidationS ummary1" runat="server" HeaderText="Err ors!! Please correct the following:"
ShowSummary="Fa lse" ShowMessageBox= "True"></asp:validations ummary> </td>
</tr>
</table>
</form>

from code behind

if(Page.IsValid )
{
HttpFileCollect ion myFiles = Request.Files;
HttpPostedFile myFile = myFiles[0];

MailingListDB mlDB = new MailingListDB() ;
if((bool)ViewSt ate["isAdd"] == true)
{
mlDB.AddNewMail er(txtSubject.T ext.Trim(), txtBody.Text,
txtNavigateURL. Text.Trim(), ref myFile);
}
else
{
mlDB.UpdateExis tingMailer((int )ViewState["MailerID"],
txtSubject.Text .Trim(), txtBody.Text, txtNavigateURL. Text.Trim(), ref
myFile);
}

if(ViewState["URLReferre r"] != null)
{
Response.Redire ct(Convert.ToSt ring(ViewState["URLReferre r"]));
}
else
{
Response.Redire ct("~");
}
}

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Grant Harmeyer" <ne*@internetap ollo.com> wrote in message
news:eB******** ******@TK2MSFTN GP10.phx.gbl...
I have an application that uses FreeTextBox 2.0
(http://www.freetextbox.com). FreeTextBox is a rich text editor that
behaves
similarly to MS Word. The FreeTextBox control has a button to
insert images
(just as you would with MS Word) and it works beautifully. The
problem is that when you include an image with the rich text editor, the image path is
the local path on the client. I have written a method that examines
the text
for <img> tags, extracts the local path, and then replaces it with
what the
virtual path will be after the file has been saved to the server.

I would like post the file to the server as I would with an
HtmlInputFile (PostedFile) control using the HttpPostedFile object, but it would appear that this is not allowed. After doing some digging, it looks like my best option would be to write a Web Service that accepts the image as a byte array and use the WebClient object to upload the file to the service.
It sounds like this would work but I don't really know how to approach this.
I would rather just straight post the file to the

HttpPostedFileC ollection just like an HtmlInputFile control does, but that doesn't look like a possible option. If anyone knows a good means to upload a file without the HtmlInputFile control, please let me know.

TIA,

Grant Harmeyer


Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3277
by: Brian Pittman | last post by:
Hi, I was wondering how to go about creating a wrapper function for uploading files to the server? I have made an attempt on my own without success. I don't get any exceptions from the function but It doens't upload the file either. Any help is appreciated. Brian '*********************
4
2285
by: Amar | last post by:
I am trying to upload a file to the webserver through my asp.net application. The file upload works fine for files below 50 MB size because i have set the maxrequestlength property of the <httpruntime> in the machine.config file as 51200KB. whenever the user tries to upload a file which is more than 51200KB then, a blank page with DNS error is shown as soon as the user hits the submit button. I want to be able to display an error message...
3
2280
by: | last post by:
Thanks Richard and Shan, I am using the HtmlInputFile control.But Shan where exactly do you want me to put in your code? becoz,after the user selects a file to upload and hits Submit, then the flow of the code does not go into the OnClick() event of the submit button, if the filesize is > 50 Mb.I checked this by setting a breakpoint on the first line of the OnClick event. The aspx page just shows a DNS error page. Is there a way, that i...
1
1748
by: David | last post by:
Hello. I can't upload large file with HtmlInputFile control:( Is there any file size limitation in HtmlInputFile control? If yes how can I upload to server large size file? Than you.
4
2175
by: Charles A. Lackman | last post by:
Hello, I have a web site that allow visitors to upload files to my server using HTMLInputFile. Is there a way to make a file dialogbox appear during the upload like the one that appears when you download a file?? Thanks
1
1671
by: Irfan Akram | last post by:
Hi Guys, I am creating dynamic controls in asp.net. I am having problems creating dynamic Htmlinputfile controls, and even after being created I cannot view it. Is there a way of creating such a control dynamically? If so which one is it ? Ot I how can I create dynamic input file controls in asp.net: - I got the following code to build the dynamic controls. All of them are properly displayed except this input file control.
7
1453
by: chuckdfoster | last post by:
I am developing an ASP.NET site where an site administrator can upload files via ASP.NET into a Documents folder. These documents are then viewed by site users. I used the MS KB article http://support.microsoft.com/default.aspx?scid=kb;en-us;323245 to learn how to do this. Is there a security issue with this. If you are giving the ASPNET account Read & Execute, List Folder Contents, Read, and Write permissions, then could they not...
4
5430
by: Corey Erkes | last post by:
I am using ASP.Net with C# as the code behind and am trying to upload multiple files with the HTMLInputFile Control. I am able to browse, select a file, and finally upload, but only one file at a time. Is there a way to select multiple files to upload at one time using this control, or possibly another control?? Any ideas on this would be greatly appreciated!! Thank a lot! Corey
2
1480
by: Zoliq | last post by:
Hi, I have a serious problem. I'm currently developing an application in which the user should upload many files (600-700 xml files). I've searched the web for a while and so far I realized that there's no way to use the HtmlInputFile class to achive the desired effect just because I can't set programatically the property of the class that stores the path of the selected file. My first approach was to write some javascript code which would...
0
8671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9016
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2321
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.