文件上传问题(firefox有效,IE不行) [英] File upload problem(firefox works, IE not)

查看:82
本文介绍了文件上传问题(firefox有效,IE不行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨@ all,


我一直在想,没有我无法解决的问题。

但现在我改变了主意.. ....


我已经在javascript组中发布了它,因为我认为javascript

和php都涉及这个问题,我在这里发布同样。如果那个

是非法的,请删除它,谢谢。

我的问题是我使用javascript生成表单,表格

包含一个普通的文件上传器。代码是这样的:

var inputform =

document.getElementById(''inputform'');

if(!inputform) {

inputform =

document.createElement(''form'');


inputform.setAttribute(''enctype' ',''multipart / form-data'');


inputform.setAttribute(''method'',''post'');

inputform.setAttribute(''action'',

''programMotes.php'');

filetext = document.createTextNode(''Mote

可执行文件:'');


exefile = document.createElement(''input'');

exefile.setAttribute(''type'' ,''file'');

exefile.setAttribute(''name'',

''moteProgramFile'');

text2 = document.createTextNode('''');


inputButton = document.createElement(''input'');

inputButton.setAttribute(''输入'',

''submit'');

inputButton.setAttribute(''value'',

''Flash the marked motes'');

hidden =

document.createElement(''input'');

hidden.setAttribute(''type'',''hidden'');

hidden.setAttribute(''name'',''sent'');

hidden.setAttribute(''value'',''true'');

inputform.appendChild(tbl);

inputform.appendChild(filetext);

inputform.appendChild(exefile);

inputform.appendChild(text2);

inputform.appendChild(inputButton);

inputform.appendChild(hidden);

br = document.createElement(''br'');

br2 = document.createElement(''br'');


finishedText = document.createTextNode( ''Loaded。'');

inputform.insertBefore(br,filetext);

inputform.insertBefore(finishedText,

br);

inputform.insertBefore(br 2,

finishedText);

content.appendChild(inputform);

}

然后在相应的php中file moteProgramFile.php:

$ target_path =" uploads /" ;;

$ target_path = $ target_path。

basename($ _ FILES [ ''moteProgramFile''] [''name'']);

echo $ target_path;

if(move_uploaded_file($ _ FILES [''moteProgramFile''] [' 'tmp_name''],

$ target_path))

{

echo文件。 basename(

$ _FILES [''moteProgramFile''] [''name''])。

"已上传;

}

其他

{

echo"上传文件时出错,请

再试一次!" ;;

}

使用firefox,绝对没有问题,但使用IE浏览器,

文件无法上传!有人有想法吗?

提前感谢

db

解决方案

target_path =" uploads /" ;;


target_path =


target_path。

basename(

Hi@all,

I am always thinking that there is no problems that I can not solve.
But now i changed my idea......

And I have posted it in javascript group, since i think both javascript
and php are involved in this problem, i post it here as well. If that
is "illegal", please delete it, thanks.
My problem is that i use javascript to generate a form, the form
contains a normal file uploader. The code is somehow like this:
var inputform =
document.getElementById(''inputform'');
if (!inputform) {
inputform =
document.createElement(''form'');

inputform.setAttribute(''enctype'',''multipart/form-data'');

inputform.setAttribute(''method'',''post'');
inputform.setAttribute(''action'',
''programMotes.php'');
filetext=document.createTextNode('' Mote
Executable: '');

exefile=document.createElement(''input'');
exefile.setAttribute(''type'', ''file'');
exefile.setAttribute(''name'',
''moteProgramFile'');
text2=document.createTextNode('' '');

inputButton=document.createElement(''input'');
inputButton.setAttribute(''type'',
''submit'');
inputButton.setAttribute(''value'',
''Flash the marked motes'');
hidden =
document.createElement(''input'');
hidden.setAttribute(''type'', ''hidden'');
hidden.setAttribute(''name'', ''sent'');
hidden.setAttribute(''value'', ''true'');
inputform.appendChild(tbl);
inputform.appendChild(filetext);
inputform.appendChild(exefile);
inputform.appendChild(text2);
inputform.appendChild(inputButton);
inputform.appendChild(hidden);
br=document.createElement(''br'');
br2=document.createElement(''br'');

finishedText=document.createTextNode(''Loaded.'');
inputform.insertBefore(br, filetext);
inputform.insertBefore(finishedText,
br);
inputform.insertBefore(br2,
finishedText);
content.appendChild(inputform);
}
And then in corresponding php file moteProgramFile.php:
$target_path = "uploads/";
$target_path = $target_path .
basename($_FILES[''moteProgramFile''][''name'']);
echo $target_path;
if(move_uploaded_file($_FILES[''moteProgramFile''][''tmp_name''],
$target_path))
{
echo "The file ". basename(
$_FILES[''moteProgramFile''][''name'']).
" has been uploaded";
}
else
{
echo "There was an error uploading the file, please
try again!";
}
With using firefox, there is absolutely no problem, but with using IE,
the file can just not be uploaded! Does someone have an idea?
thanks in advance
db

解决方案

target_path = "uploads/";


target_path =


target_path .
basename(


这篇关于文件上传问题(firefox有效,IE不行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆