I checked your code with different kind of browser and your code is working only in "Internet Explore" and other then IE it is throwing exeception from below line
using (FileStream fs = new FileStream(cmdSelectFile.PostedFile.FileName, FileMode.Open, FileAccess.Read))
Why It is working in IE??
Because IE is upload our selected file to temp directory of server first so you are able to do the FileStream using Name only, other then IE will not do such kind of opration, you have to SAVE the Uploaded file and then do the Menupulation which ever you wants
Check below code for save the file
cmdSelectFile.SaveAs("<<FileName>>");
let me know if any query
Thanks,
Gaurav Dhol
Skype ID : dhol.gaurav
If My Post contains helped you, Please Mark as Answer
msbsam
Member
259 Points
237 Posts
FileUpload controller not working with Chrome
Jan 30, 2013 06:50 AM|LINK
That controler not working properly in chrome . When page load its showing "no file chosen" message and controller also not showing prooperly.
Once i pick the file and tried to upload ,but its not saving .Its not getting file path .
But everything working fine with IE .
dhol.gaurav
Contributor
3998 Points
725 Posts
Re: FileUpload controller not working with Chrome
Jan 30, 2013 10:13 AM|LINK
Can you share your code here?? so all can get more idea about your problem
let me know if any query
Gaurav Dhol
Skype ID : dhol.gaurav
If My Post contains helped you, Please Mark as Answer
deepthoughts
Contributor
7288 Points
1051 Posts
Re: FileUpload controller not working with Chrome
Jan 30, 2013 10:38 AM|LINK
make sure your fileupload control is not inside an UpdatePanel.
Thanks.
msbsam
Member
259 Points
237 Posts
Re: FileUpload controller not working with Chrome
Jan 31, 2013 02:40 AM|LINK
source
<form id="form1" runat="server" enctype="multipart/form-data">
<div>
<asp:FileUpload ID="cmdSelectFile" runat="server" Width="544px" />
<br />
<asp:Button ID="cmdUpload" runat="server" Text="Upload" OnClick="cmdUpload_Click" />
<asp:Label ID="lblMessage" runat="server"></asp:Label>
</div>
</form>
.cs
protected void cmdUpload_Click(object sender, EventArgs e)
{
try
{
if (cmdSelectFile.HasFile)
{
string fileExt =System.IO.Path.GetExtension(cmdSelectFile.FileName);
FTWS ft = new FTWS();
string tempFileName = ft.GetTempFilename();
using (FileStream fs = new FileStream(cmdSelectFile.PostedFile.FileName, FileMode.Open, FileAccess.Read))
{
using (BinaryReader br = new BinaryReader(fs))
{
fs.Position = 0;
int numBytesToRead = (int)fs.Length;
int numBytesRead = 0;
while (numBytesToRead > 0)
{
//I choose 100 000 bytes long blocks.
byte[] b = br.ReadBytes(100000);
ft.AppendToTempFile(tempFileName, b);
if (b.Length == 0)
{
break;
}
numBytesRead += b.Length;
numBytesToRead -= b.Length;
//When block is saved, than we can update pbTransferStatus value
int progressStatus = (int)((double)100 /
(double)fs.Length * (double)numBytesRead);
}
ft.SaveFileIntoDatabase(cmdSelectFile.FileName, tempFileName, cmdSelectFile.PostedFile.FileName);
lblMessage.Text = "File successfuly uploaded";
}
}
}
else
{
lblMessage.Text = "You have not specified a file.";
}
}
catch (Exception err)
{
}
}
Here few methods in Webservie class . I think you can run without cs event.
Thanks
dhol.gaurav
Contributor
3998 Points
725 Posts
Re: FileUpload controller not working with Chrome
Jan 31, 2013 04:27 AM|LINK
I checked your code with different kind of browser and your code is working only in "Internet Explore" and other then IE it is throwing exeception from below line
Why It is working in IE??
Because IE is upload our selected file to temp directory of server first so you are able to do the FileStream using Name only, other then IE will not do such kind of opration, you have to SAVE the Uploaded file and then do the Menupulation which ever you wants
Check below code for save the file
cmdSelectFile.SaveAs("<<FileName>>");let me know if any query
Gaurav Dhol
Skype ID : dhol.gaurav
If My Post contains helped you, Please Mark as Answer
msbsam
Member
259 Points
237 Posts
Re: FileUpload controller not working with Chrome
Jan 31, 2013 07:03 AM|LINK
Thanks for your reply.
Yes its working with InternetExplore . I removed my code ( used new page with only upload controler) and open with Chrome . It has same problem .
I t seems that controler is not supporting to chrome ( :( not sure ) . And i used VS 2005 and chrome 18.0.1025.168 m version.
shivanand G ...
Participant
1763 Points
534 Posts
Re: FileUpload controller not working with Chrome
Jan 31, 2013 07:13 AM|LINK
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="ShiVU_Application.WebForm2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script> var messageText; function checkMessage() { if (messageText != null) alert(messageText); } </script> </head> <body onload="checkMessage();"> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> </div> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <!-- Here your Upload Control.. --> <asp:FileUpload id="FileUploadControl" runat="server" /> <asp:Button runat="server" id="UploadButton" text="Upload" onclick="UploadButton_Click" /> </ContentTemplate> </asp:UpdatePanel> </div> <div> <asp:UpdateProgress ID="UpdateProgress1" runat="server"> <ProgressTemplate> <asp:Label ID="CheckingSizeLabel" runat="server" Text="Please Wait! Checking Size..."></asp:Label> </br> <asp:Label ID="CheckLandScapeLabel" runat="server" Text="Please Wait! Checking Resolution..."></asp:Label> </ProgressTemplate> </asp:UpdateProgress> </div> </form> </body> </html>shivanand.G.N (shivu.betta@gmail.com)
dhol.gaurav
Contributor
3998 Points
725 Posts
Re: FileUpload controller not working with Chrome
Feb 01, 2013 03:54 AM|LINK
Hi,
Remove "UpdatePanel", File Upload control will not work inside the Update Panal
let me know if any query
Gaurav Dhol
Skype ID : dhol.gaurav
If My Post contains helped you, Please Mark as Answer
msbsam
Member
259 Points
237 Posts
Re: FileUpload controller not working with Chrome
Feb 01, 2013 06:24 AM|LINK
I dont use any update panel. pls see my code
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<div>
<asp:FileUpload ID="cmdSelectFile" runat="server" Width="544px" Font-Names="Tahoma" Font-Size="10pt" />
<br />
<asp:Button ID="cmdUpload" runat="server" Text="Upload" OnClick="cmdUpload_Click" Font-Names="Tahoma" Font-Size="10pt" />
<asp:Label ID="lblMessage" runat="server" Font-Names="Tahoma" Font-Size="10pt" ForeColor="MediumBlue"></asp:Label>
<br />
<asp:HyperLink ID="hlSearch" runat="server" Font-Names="Tahoma" Font-Size="10pt"
ForeColor="Blue" NavigateUrl="~/FTW/SearchFile.aspx" Font-Underline="False">Back to Search</asp:HyperLink></div>
</form>
</body>
</html>