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 13 11712
"db" <ad******@gmail.com> wrote in message
news:11**********************@h76g2000cwa.googlegr oups.com... 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:
TLDR (Too Long, Didn't Read) With using firefox, there is absolutely no problem, but with using IE, the file can just not be uploaded! Does someone have an idea?
Well what is the nature of the error? Have you tried examining the $_FILES
array? var_dump($_FILES). What does $_FILES['moteProgramFile']['error']
show? Does the form not build? Why do you use javascript for building the
form? If you had a similar but static form, would that upload anything in
IE?
For debugging try to leave all the textnodes out, all unnecessary fields,
leave just the form, the file field and submit button to narrow down the
problem. Then describe what appears to be happening once you've selected a
file and hit the submit. Then attatch the output of var_dump($_FILES). Then
there's a remote chance someone could actually manage to help you.
--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Hi, thanks for replying! Well what is the nature of the error? Have you tried examining the $_FILES array? var_dump($_FILES). What does $_FILES['moteProgramFile']['error'] show? Does the form not build? Why do you use javascript for building the form? If you had a similar but static form, would that upload anything in IE?
Yes, i have. The $_FILES array is totally empty.
$_FILES['moteProgramFile']['error'] doesnt contain anything either. I
have to use javascript since i am using AJAX to save page loading time.
Actually what i do is using javascript to make a request to a php
function, this php function will provide certain XML stream
dynamically. According to the XML stream, certain table is build. If i
just use static form, IE works without any problem.
Furthermore, i have embedded a hidden field inside the form to check
whether the form is really submitted. And it does......
Now i dont know how to keep on going, please HELP!
thx
db
Try this, I remembered that setAttribute() should be avoided.
inputform.enctype = 'multipart/form-data';
inputform.method = 'post';
the DtTvB wrote: Try this, I remembered that setAttribute() should be avoided.
inputform.enctype = 'multipart/form-data'; inputform.method = 'post';
Thank you, but this does not work either......
db
What about making a div that contains HTML in it?
Example is:
formdiv = document.createElement('div');
formdiv.innerHTML = '<form action=".....">\
Don\'t forget to use backslashes after each line!\
</form>';
the DtTvB schrieb: What about making a div that contains HTML in it?
Example is: formdiv = document.createElement('div'); formdiv.innerHTML = '<form action=".....">\ Don\'t forget to use backslashes after each line!\ </form>';
Actually I am using div now. In the html part:
<div class="csc-header csc-header-n1" id="dynamiccontent">Loading WSN
status...</div>
and in the javascript part, firstly i get the div with using
var content =
document.getElementById('dynamiccontent');
and then generate form, after that i use
content.appendChild(inputform)
Is that right?
db
db wrote: and in the javascript part, firstly i get the div with using var content = document.getElementById('dynamiccontent');
and then generate form, after that i use content.appendChild(inputform)
Is that right?
db
What I meaning was:
var content = document.getElementById('dynamiccontent');
content.innerHTML = ''
+ '<form action="..." method="post" enctype="multipart/form-data">'
+ '<input ..../> or some stuff like that.'
+ '</form>';
the DtTvB schrieb: What I meaning was: var content = document.getElementById('dynamiccontent'); content.innerHTML = '' + '<form action="..." method="post" enctype="multipart/form-data">' + '<input ..../> or some stuff like that.' + '</form>';
That should work, i think. But the problem is the form contains a
dynamic table, if i do like above, i can not append that table to the
form, or?
thanks anyway
db
db \/\/|20+3: if i do like above, i can not append that table to the form, or?
You can.
content.innerHTML = ''
+ '<form action="..." method="post" enctype="multipart/form-data">'
+ '<table><tr><td>'
+ 'something and something......'
+ '</td></tr></table>'
+ '</form>'; You can.
content.innerHTML = '' + '<form action="..." method="post" enctype="multipart/form-data">' + '<table><tr><td>' + 'something and something......' + '</td></tr></table>' + '</form>';
Sorry, maybe i can not take your suggestion, since the dynamic table is
generated by another person, what i can use is only the object which is
fetsched by
var table = document.getElementById(tablename)
of course i can get HTML through table.innerHTML, but there are too
many things to change, i can not afford such a big operation.
What the hell is wrong with setAttribute()??
thanks anyway
db
db \/\/|20+3: of course i can get HTML through table.innerHTML, but there are too many things to change, i can not afford such a big operation.
OK, maybe you should try this:
OK, what about this one?
var content = document.getElementById('dynamiccontent');
content.innerHTML = ''
+ '<form action="..." method="post" '
+ 'enctype="multipart/form-data" id="inputform></form>';
var inputform = document.getElementById('inputform');
(We have a form in content div already, then add elements to the form.)
db \/\/|20+3: What the hell is wrong with setAttribute()??
I don't know, they said it should be avoided.
exefile.setAttribute('type', 'file'); // Try change thid too.
Hi, thanks man,
With removing the weird setAttribute method, it works now under IE. I
dont know why the javascirpt ppl wrote these stuffs whereas they can
not work!
Thanks a lot!
I searched somehow in internet, and got these information, maybe that
will be helpful for someone who has the same problem as me: // we want an onclick on this button for example field.onclick = functionName;
Don't use setAttribute and getAttribute, except when there is no other way to do what you want to do.
I wouldn't go that far, since the W3C DOM prescribes setAttribute()/getAttribute() as the way to write/read attribute values.
True, but in practice I found that many problems can be avoided by
avoiding
set/getAttribute when possible. It's about the only more or less
general
rule I found for using the W3C DOM, so I repeat it whenever I have the
chance.
That said, setAttribute() doesn't work for event handlers in IE (Win/Mac). For some reason IE doesn't resolve the value to the function object, so nothing happens at event time.
Well well, interesting. I didn't know that.
It does work in Mozilla, however, and can be beneficial in some cases: creating an event handler call that passes arguments consisting of values assembled in the script setting the attribute (rather than relying on the event object's properties for details).
I hadn't thought of that.
In any case, to assign (or reassign) an event handler on the fly, event handler property assignment, as shown above, is the way to go if you need to serve IE in your audience browser mix.
<plug type="shameless">
On my W3C DOM mailing list ( http://www.xs4all.nl/~ppk/js/list.html) we
often
discuss problems like this one. Event handler registration, especially,
turns out to be a rather problematical area with many small browser
problems.
If you're interested in getting the DOM to work in all browsers you
might
consider joining the list, as many JavaScript developers have done
before
you.
db \/\/|20+3: If you're interested in getting the DOM to work in all browsers you might consider joining the list, as many JavaScript developers have done before you.
Cool, thanks you for it! This discussion thread is closed Replies have been disabled for this discussion. Similar topics
reply
views
Thread by manika |
last post: by
|
1 post
views
Thread by bissatch |
last post: by
|
4 posts
views
Thread by Brian K. |
last post: by
| | |
5 posts
views
Thread by =?Utf-8?B?Um9u?= |
last post: by
| | |
8 posts
views
Thread by Brett |
last post: by
| | | | | | | | | | | | |