How to Get Full Path of FileUploadField by JAVASCRIPT or listerner
Hi All,
I have a FileUploadField inside a GridPanel.
I want to get the full name from javascript or using listeners or AjaxMethod.
Its working fine in IE 7 i am getting the full Path by using the code, but not getting full path name in Mozilla or google chrome using the code below , there " (#{fileAttachment}.getValue())" give me the full path name in IE but not in mozilla or chrome..
I mean if in IE its give me the path like.. "C:\\UploadedFile\Files\MyuploadFile.jpg"
but in Mozilla or chrome its give me only " MyuploadFile.jpg".
My FileUploadField is inside the Gridpanel , so i donot know how to use .. "fileAttachment.FileName" or "fileAttachment.PostedFile.FileName".
Code:
<ext:Column DataIndex="FILENAME" Header="Add Attachment" Width="140px">
<Editor>
<ext:FileUploadField runat="server" ID="fileAttachment" ButtonOnly="true" ButtonText="Add File"
AllowBlank="true">
<Listeners>
<FileSelected Handler="#{AjaxMethods}.GetFileName(#{fileAttachment}.getValue());" />
</Listeners>
</ext:FileUploadField>
</Editor>
</ext:Column>
[AjaxMethod]
public void GetFileName(string strValue)
{
// its work in IE but not work in Mozilla.
int _intIndex = strValue.LastIndexOf('\\');
string strFileName = strValue.Substring(_intIndex+1);
}
Can you please help me to get the full file path (like C:\\UploadedFile\Files\MyuploadFile.jpg instead of just "MyuploadFile.jpg) on client side.
Thanks and Regards
Kunal Mehata.
India
919971261098
RE: How to Get Full Path of FileUploadField by JAVASCRIPT or listerner
Hi,
It is impossible due security reason, all modern browsers doesn't provide path (file name only)
RE: How to Get Full Path of FileUploadField by JAVASCRIPT or listerner
Hi Vladsch,
Is there any way to get the FileUploadField assigned file in server side, where FileUploadField is INSIDE A GRIDPANEL.
like ..
Code:
public void GetFileName(string strValue)
{
int _intIndex = strValue.LastIndexOf('\\');
string strFileName = strValue;
if (_intIndex > 0)
{
strFileName = strFileName.Substring(_intIndex + 1);
}
if (!string.IsNullOrEmpty(fileAttachment.FileName))
{
fileAttachment.PostedFile.SaveAs(Server.MapPath("TEMPFILE\\" + strFileName));
}
}