On Jan 27, 10:02 am, itised83 <[EMAIL PROTECTED]> wrote:
> > In the meantime I assigned the file input to a hidden type input and
> > processed that. It worked great.
>
> And... how did you do that? :) I have same problem
This was an odd problem, I actually needed just the basename within
the page and yet I also needed to send the full path. It was as if I
needed the exact opposite as to what the HTML spec mentioned above
performed.
So I added an "onchange" attribute to the input element for inputting
the file type.
<input size="25" name="script_browse_path"
onchange="this.form.script_name.value=get_filename(this.form.script_browse_path.value);
this.form.script_path.value=this.form.script_browse_path.value;"
type="file">${script_meta['script_path']}</input>
<input type="hidden" name="script_path"/>
So, here we have the following:
"script_name" is a text input field (readonly) that displays just the
basename by using the following javascript function:
function get_filename(script_path)
{
var split_char = "\\"
var path_array = script_path.split(split_char);
var file_name = path_array.pop();
return (file_name)
}
Note that this is windows specific as that is what the clients are all
currently. I haven't researched a way to make it cross platform, I
guess that would be to detect the OS and use '/' or '\\' as the
directory separators. Too bad I can't just use os.path methods :)
Second, please notice that I have created a hidden input field named
"script_path" that the "onchange" action assigns to. I send this
value back to cherrypy so I can have the full path.
So when you change the value of the file type field (entering the
value from the popup dialog) two fields are updated but only one is
relevant for my needs and is hidden.
This way I have a more attractive basename (filename) displayed for
the user while I am sending the full file path back to TG for
processing. (e.g. turning a drive letter mapped drive into a UNC
path)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---