This topic is locked

How to only have browser field an not file name field

1/15/2011 7:17:45 PM
PHPRunner General questions
R
rstackhouse author

The default (?) method of a file is to have a file field and browser button AND a "file name" button.
How do you make it so the file name is preselected by the system and not selectable -- aka I want my own file name to be generate.

Sergey Kornilov admin 1/16/2011

This is how browsers work. You cannot pre-populate file name field. It would be a huge security hole if you could.
You can change uploaded file name on the server side though. Check this article for reference:

http://xlinesoft.com/phprunner/docs/rename_uploaded_file.htm

R
rstackhouse author 1/25/2011

No, perhaps we've not communicated...
I want the button to browse, but there is also a field where it asks for File name.. so 3 items

  1. text field for path/file of file on users computer.
  2. browse button
  3. another field for file name ON THE SERVER.
    I want to just generate a name for #3 NOT specify the file path/name on the user's computer.
    As it stands its sort of a security risk to be able to specify the file (item #3) as you dont know if ../../../passwd or something might happen -- it does seem protected, but I dont think they should be able to specify it...
    Are we still talking past each other?
    Thanks

Sergey Kornilov admin 1/25/2011

I see what you mean, assumed you talking about file name on clients machine.
It sure possible with three fields. Check the following articles.
Adding a custom field to the form:

http://xlinesoft.com/phprunner/docs/add_custom_field_to_form.htm
Renaming uploaded files:

http://xlinesoft.com/phprunner/docs/rename_uploaded_file.htm
For security reasons you may want to sanitize input removing slashes from entered file name.