This topic is locked

Upload images or documents depending on username

6/8/2007 1:48:42 AM
PHPRunner General questions
R
rainerwolf author

I want to upload images or documents to a specific folder depending on benutzername (login-field from my table), please can give me the solution.

I have tried it with Edit as File/image and upload folder $data["benutzername"]/files but is doesn't work.
Kind regards

Rainer

Alexey admin 6/8/2007

Rainer,
at first add a calculated field to your SQL query and use it on View and List pages.

I.e.

select

...

concat(benutzername,'/files/',filenamefield) as file,

...

Set this field to be displayed as File with empty prefix and set the original field editable as File with empty upload folder.
Then add this code to Before record updated/edited events:

global $files_move;

foreach ($files_move as $key=>$file)

{

$files_move[$key][1]=$values["benutzername"]."/files/".$files_move[$key][1];

}


Please note that you'll need to create all benutzername/files folders manually.

R
rainerwolf author 6/8/2007

Thanks Alexey,

but when i must manually generate the directories, then i need another solution.
When i use the default directory "files" in my file upload field, i must save the uploaded files

(up to 10 files = 10 input fields ), like "benutzername.document.pdf" or "benutzername.document.doc" on my file server.
where "benutzername"=benutzername Field from customers table
And the result must be:
"benutzername.document1.pdf" from file input depending on upload filename

"benutzername.document1.doc" from file input depending on upload filename
and so on
What can i do?
Kind regards

Rainer Wolf

Alexey admin 6/8/2007

Rainer,
in this case use "." istead of "/files/" in code snippets from my previous post.

R
rainerwolf author 6/8/2007

Alexey,
i have still problems with your solution. I uploaded my project to my demo account.
demo/demo

Alexey admin 6/8/2007

Rainer,
send a link to your project at demo account to support@xlinesoft.com