hi everyone,

have one upload form to enable uploading attachments. I set the max
amount to 5 files.

now after the files got uploaded i want cake to render the names in a
DIV, so the user sees what files he uploaded. so far everything works.
the upload, the check for max files uploaded and also the rendering.
EXAMPLE:

user uploaded 3 files. does a 4th. this is my logic

1) count the files user uploaded --> 4

2) Because its 4, write the path from this one to the session variable
4:
$this->Session->write('Link.Attachment.4.Path', "../link/
tmp/........");

3) set the variable for the view and call it
        $this->set('link_attachment_4', ($this->Session-
>read('Link.Attachment.4.Path')));

        $this->render('render_attachment','ajax');

4) now render the view that echos the Path from all uploaded file
                echo $link_attachment_1;
                echo '<br>';
                echo $link_attachment_2;
                echo '<br>';
                echo $link_attachment_3;
                echo '<br>';
                echo $link_attachment_4;
                echo '<br>';
                echo $link_attachment_5;

it works fine. user upload 1-5 files, they all get uploaded and echoed
correctly. but my logic brings trouble due to assigning the upload
file path to a session variable regarding to the file count.

lets say you delete the 2nd file of those 5. then
$this->Session->write('Link.Attachment.2.Path', "../link/
tmp/........");

is FREE. but because everything is static there will be a space
between the 1st and 3rd echoed file, since
echo $linkables_attachment_2 is empty.

ALSO:
if you upload a new file, for your deleted one, my logic will count 5
files again and allocate this file path to
$this->Session->write('Link.Attachment.5.Path) which is wrong, since
it should write it in the session variable that got free, the 2nd.
RESULT: 2nd variable stays free, 5th gets replaced..

long story short. i need an algorithm, that dynamically allocates
files paths to the first FREE variable. like an array and cake find
the first free spot and writes the path there.

then i could loop through that array in my view "render_attachment"
and just echo the field that are filled.

and if a user deletes a file, cake has to find the related field in
that array to empty it, and also delete it from the directory.

.so i got the logic, but i dont kow how to code this...any idea?

thx :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" 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/cake-php?hl=en

Reply via email to