我现在在一个页面中上传多张图片,对应不同的类别(如:位置图,平面图,图片数量可以根据客户的需要添加的,<input type='file' />是用js生成的),在页面提交之前我在js中把每个类别的<input type='file' />的value赋值给一个隐藏控件以便在.cs中保存的时侯好区分,我在保存的时侯:
string fileName = 。;
string SoftDown = Request.Form["hidSoftDown"];
HttpFileCollection files = Request.Files;
for (int i = 0; i < files.Count; i++)
{
string oldFile = files[i].FileName.Trim();
if (SoftDown.IndexOf(oldFile) >= 0)
{
SoftDown = SoftDown.Replace("<Path>" + oldFile + "</Path>", "<Path>" + fileName + "</Path>");
。。
但是结果是:
files[i].FileName在IE中它获取的值是:C:\AA\A.TXT
在firefox中它获取的值是:A.TXT,造成上面SoftDown的值没有被修改
-----------------------------------
我该怎么办呢?或者对于我这种情况还有其他好的处理方式吗?
string fileName = 。;
string SoftDown = Request.Form["hidSoftDown"];
HttpFileCollection files = Request.Files;
for (int i = 0; i < files.Count; i++)
{
string oldFile = files[i].FileName.Trim();
if (SoftDown.IndexOf(oldFile) >= 0)
{
SoftDown = SoftDown.Replace("<Path>" + oldFile + "</Path>", "<Path>" + fileName + "</Path>");
。。
但是结果是:
files[i].FileName在IE中它获取的值是:C:\AA\A.TXT
在firefox中它获取的值是:A.TXT,造成上面SoftDown的值没有被修改
-----------------------------------
我该怎么办呢?或者对于我这种情况还有其他好的处理方式吗?
if(window.ActiveXObject){
//IE
}else{
//其他浏览器
}
var table = document.getElementById(Table);
var str = "";
for(var i = 1; i < table.rows.length; i ++)
{
var row = table.rows[i];
var order = Trim(row.cells[3].getElementsByTagName("input")[0].value);
if(row.cells[1].getElementsByTagName("input")[0].value != "")
{
if(row.cells[1].getElementsByTagName("input")[0].type == "file")
{
var file = Trim(row.cells[1].getElementsByTagName("input")[0].value);
str += "<File><Path>" + file + "</Path><Desc>"
+ Trim(row.cells[2].getElementsByTagName("input")[0].value) + "</Desc><Order>"
+ order + "</Order><Size>"
+ file + "</Size></File>";
。
try:var file = Trow.cells[1].getElementsByTagName("input")[0].value;
var index = file.lastIndexOf("\\");
if(index > 0)
file = file.substr(index+1);str += "<File><Path>" + file + "</Path><Desc>"
+ Trim(row.cells[2].getElementsByTagName("input")[0].value) + "</Desc><Order>"
+ order + "</Order><Size>"
+ file + "</Size></File>";
现在我想知道有什么方法获取那些js生成的<input type='file' />控件的ID没?或者有什么比我这种方法更好的方法代替我的做法没?