You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Daniel Hertz <da...@shaw.ca> on 2006/02/27 04:02:33 UTC

IE filepath error in flowscript - tried getName

The following file upload flowscript which works great in Mozilla, but 
not at all in Internet Explorer (IE includes the entire path instead of 
just the filename, e.g. filename = "filename.jpg"; but IE sends 
"Z:/my/path/to/filename.jpg").

I tried getName(), but couldn't get it to work. Any suggestions? Thanks! 
Daniel.

== Flowscript ==

[SNIP]

 cocoon.sendPage("upload",
     {
         filename: 
form.lookupWidget("upload").getValue().getHeaders().get("filename").toLowerCase() 

     }
 );

function handleUpload(form) {

[SNIP]

 var fileName = 
form.lookupWidget("upload").getValue().getHeaders().get("filename").toLowerCase(); 


 var uploadWidget = form.lookupWidget("upload");
 if (uploadWidget.getValue() != null) {
         // test if user directory exists, if not, create it
      if (!userDir.exists())
        {
        userDir.mkdirs();
        }
   uploadWidget.getValue().copyToFile(userDir + java.io.File.separator + 
fileName);
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: IE filepath error in flowscript - tried getName

Posted by Tony Edwards <te...@civica.com.au>.
Whoops,
Having just sent off the last mail I went back over my code and found 
that I had removed the substringing process for this:

    var fileName = 
form.getChild("upload").getValue().getHeaders().get("filename");

    var aTempFile = new Packages.java.io.File(fileName);
   
    print("Separator: " + aTempFile.separator);   
    print("########## Filename getName() = " + aTempFile.getName());
    fileName = aTempFile.getName();

Cast the returned fileName in to a file object then use the getName() 
method on that. Seems to work for both Moz and IE.

Sorry about the confusion!

Regards,
Tony


Tony Edwards wrote:
> Hi Daniel,
> I recall having the same problem a while back. I trolled around and 
> found some javascript that would remove all but the filename (work 
> from the end of the string until you find the first '\' kind of thing).
> Its pretty dodgy but then again, so's IE!!
> If you get stuck I'll see if I can dredge up the code.
>
> Regards,
> Tony
>
> Daniel Hertz wrote:
>> The following file upload flowscript which works great in Mozilla, 
>> but not at all in Internet Explorer (IE includes the entire path 
>> instead of just the filename, e.g. filename = "filename.jpg"; but IE 
>> sends "Z:/my/path/to/filename.jpg").
>>
>> I tried getName(), but couldn't get it to work. Any suggestions? 
>> Thanks! Daniel.
>>
>> == Flowscript ==
>>
>> [SNIP]
>>
>> cocoon.sendPage("upload",
>>     {
>>         filename: 
>> form.lookupWidget("upload").getValue().getHeaders().get("filename").toLowerCase() 
>>
>>     }
>> );
>>
>> function handleUpload(form) {
>>
>> [SNIP]
>>
>> var fileName = 
>> form.lookupWidget("upload").getValue().getHeaders().get("filename").toLowerCase(); 
>>
>>
>> var uploadWidget = form.lookupWidget("upload");
>> if (uploadWidget.getValue() != null) {
>>         // test if user directory exists, if not, create it
>>      if (!userDir.exists())
>>        {
>>        userDir.mkdirs();
>>        }
>>   uploadWidget.getValue().copyToFile(userDir + java.io.File.separator 
>> + fileName);
>> }
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>

-- 
Tony Edwards
¯¯¯¯¯¯¯¯¯¯¯¯
Analyst/Programmer
Dip Teach PE  
Dip Comp. Studies
p: 02 4941 9400
f: 02 4941 9499


--

This email is from Civica Pty Limited and it, together with 
any attachments, is confidential to the intended recipient(s) 
and the contents may be legally privileged or contain 
proprietary and private information. It is intended solely 
for the person to whom it is addressed. If you are not an 
intended recipient, you may not review, copy or distribute 
this email. If received in error, please notify the sender 
and delete the message from your system immediately. Any 
views or opinions expressed in this email and any files 
transmitted with it are those of the author only and may 
not necessarily reflect the views of Civica and do not create 
any legally binding rights or obligations whatsoever. Unless 
otherwise pre-agreed by exchange of hard copy documents 
signed by duly authorised representatives, contracts may not 
be concluded on behalf of Civica by email. Please note that 
neither Civica nor the sender accepts any responsibility for 
any viruses and it is your responsibility to scan the email 
and the attachments (if any). All email received and sent by 
Civica may be monitored to protect the business interests of 
Civica. 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: IE filepath error in flowscript - tried getName

Posted by Tony Edwards <te...@civica.com.au>.
Hi Daniel,
I recall having the same problem a while back. I trolled around and 
found some javascript that would remove all but the filename (work from 
the end of the string until you find the first '\' kind of thing).
Its pretty dodgy but then again, so's IE!!
If you get stuck I'll see if I can dredge up the code.

Regards,
Tony

Daniel Hertz wrote:
> The following file upload flowscript which works great in Mozilla, but 
> not at all in Internet Explorer (IE includes the entire path instead 
> of just the filename, e.g. filename = "filename.jpg"; but IE sends 
> "Z:/my/path/to/filename.jpg").
>
> I tried getName(), but couldn't get it to work. Any suggestions? 
> Thanks! Daniel.
>
> == Flowscript ==
>
> [SNIP]
>
> cocoon.sendPage("upload",
>     {
>         filename: 
> form.lookupWidget("upload").getValue().getHeaders().get("filename").toLowerCase() 
>
>     }
> );
>
> function handleUpload(form) {
>
> [SNIP]
>
> var fileName = 
> form.lookupWidget("upload").getValue().getHeaders().get("filename").toLowerCase(); 
>
>
> var uploadWidget = form.lookupWidget("upload");
> if (uploadWidget.getValue() != null) {
>         // test if user directory exists, if not, create it
>      if (!userDir.exists())
>        {
>        userDir.mkdirs();
>        }
>   uploadWidget.getValue().copyToFile(userDir + java.io.File.separator 
> + fileName);
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

-- 
Tony Edwards
¯¯¯¯¯¯¯¯¯¯¯¯
Analyst/Programmer
Dip Teach PE  
Dip Comp. Studies
p: 02 4941 9400
f: 02 4941 9499


--

This email is from Civica Pty Limited and it, together with 
any attachments, is confidential to the intended recipient(s) 
and the contents may be legally privileged or contain 
proprietary and private information. It is intended solely 
for the person to whom it is addressed. If you are not an 
intended recipient, you may not review, copy or distribute 
this email. If received in error, please notify the sender 
and delete the message from your system immediately. Any 
views or opinions expressed in this email and any files 
transmitted with it are those of the author only and may 
not necessarily reflect the views of Civica and do not create 
any legally binding rights or obligations whatsoever. Unless 
otherwise pre-agreed by exchange of hard copy documents 
signed by duly authorised representatives, contracts may not 
be concluded on behalf of Civica by email. Please note that 
neither Civica nor the sender accepts any responsibility for 
any viruses and it is your responsibility to scan the email 
and the attachments (if any). All email received and sent by 
Civica may be monitored to protect the business interests of 
Civica. 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org