This topic is locked

variable upload directory

12/10/2006 5:07:43 PM
PHPRunner General questions
L
longshanks author

Hello,
I was wondering if it is possible to upload images or files to a variable location based on primary key.
I have used events to create the directory and move the files into the directory associated with the primary key, the problem now is that phprunner doesn't know where the files are.
Right now phprunner tries to locate the files in ../upload/ but the files are in ../upload/1215 (1215 is the primary key).
I have tried to enter ../upload/$data["Id"] in the Visual Editor properties box on the ..._list.php page, but it doesn't work.
Can you help?
Thanks,

Longshanks.
P.S PHPRunner Is awsome

Alexey admin 12/11/2006

Hi,
if you use Dociment download view type you need to modify generated ..._download.php file this way.

Find these lines there

$filesize = filesize(GetUploadFolder($field).$filename);

...

$file=fopen(GetUploadFolder($field).$filename,"rb");

and replace them with:

$filesize = filesize(GetUploadFolder($field).$data["Id"]."/".$filename);

...

$file=fopen(GetUploadFolder($field).$data["Id"]."/".$filename,"rb");

L
longshanks author 12/11/2006

Hi Alexey,
It is setup as image on the ..._list.php and the ..._view.php page. it is not a downloadable file. does that make a difference in your reply?
Longshanks.

Alexey admin 12/12/2006

Hi,
in this case you can use calculated field in SQl query.

I.e. modify SQL query on Edit SQL query tab thsi way:

select

...

concat(ID,'/',Image) as IMG,

...

from ...



where ID and Image are your actual field names.
Then use IMG field to display images on your pages.