This is a migrated thread and some comments may be shown as answers.

[Solved] fileupload from excel to radgrid reading from server but need read from client

3 Answers 200 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon-Jon Kershaw
Top achievements
Rank 2
Jon-Jon Kershaw asked on 05 Jun 2009, 03:33 PM
I have fileupload1 being used by client to upload excel file to radgrid and then to DB.  Problem is the fileupload reads the server location and not the client location of the file before uploading to the radgrid.  So not really sure what to do?  I've researched some people saying it isn't possible to read the location of client side due to security but it's the client side upload so don't know why that wouldn't work.  Here is some of my code because it still reads from server so I don't know what else to do.

    protected void btnView_Click(object sender, EventArgs e)  
    {  
        string filename = FileUpload1.FileName.ToString();  
        this.ocAccounts = this.oExcelHelper.LoadExcel(filename);  
        rgBulkEntry.DataSource = this.ocAccounts;  
        rgBulkEntry.DataBind();  
        Session.Add("Accounts"this.ocAccounts);  
    } 

permissions on that server have been granted to network service and aspnet....

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Jon-Jon Kershaw
Top achievements
Rank 2
answered on 08 Jun 2009, 08:43 PM
anyone?
0
Bruno
Top achievements
Rank 2
answered on 11 Jun 2009, 10:25 AM
If I understood your scenario correctly, you want to access a file which is located on client's computer from the server, correct? If this is the case I'm afraid it is not possible. You should use the binary stream which is uploaded by the client (and which can be retrieved from the fileupload control)  instead of trying to access the actual file by its name server-side.

-- Bruno
0
Jon-Jon Kershaw
Top achievements
Rank 2
answered on 11 Jun 2009, 06:21 PM
I added this to the code and gave the person access to the folder and it worked.

 

string file = "C:\\Up\\" + Path.GetFileName(FileUpload1.FileName);

 

FileUpload1.SaveAs(file);

Tags
Grid
Asked by
Jon-Jon Kershaw
Top achievements
Rank 2
Answers by
Jon-Jon Kershaw
Top achievements
Rank 2
Bruno
Top achievements
Rank 2
Share this question
or