Jerker
Posts: 4
|
| Posted: 05/14/2010, 12:29 AM |
|
I make a thumbnail of the file in a file upload component in one of my projects. Everything works great but with one little problem. I want to delete the thumbnail when the main file is deleted.
I have tried to do this in the afterdeletefile event with following code without success.
$filename = "../bilder/tn/" .$prylar->FileUpload1->GetValue();
unlink($filname);
Why is it not working?
|
 |
 |
Gena
Posts: 591
|
| Posted: 05/14/2010, 12:40 AM |
|
Check this - unlink($filname);
should it be
unlink($filename);
?
Also check if your file exists and then delete like this
if(file_exists($filename)) {
@unlink($filename);
} else {
echo $filename . " doesn't exist";
}
_________________
Gena |
 |
 |
Jerker
Posts: 4
|
| Posted: 05/14/2010, 2:25 AM |
|
oops, that was a typo in this example, but not in the real code.....
I tried your example, with the same result. Absolutely nothing happens.... No output from the echo statement and the thumbnail is still there.....
I add the following to se that the event fires of and the filename is correct:
$fh = fopen("../bilder/tn/" .'logg.html', 'a');
fwrite($fh, $filename);
fclose($fh);
The event fires as expected but the filename is missing. In my log file is only the path, no filename. So i know that everything except the $prylar->FileUpload1->GetValue() works as expected. .
I did the same in before delete with the same result.
Is there anny good solution to fetch the filename in the delete process?
|
 |
 |
magus
Posts: 98
|
| Posted: 05/15/2010, 10:15 AM |
|
Hi,
It is possible that the Upload component deletes the deleted filename references when it deletes the file.
I suggest you run
print_r( $prylar->FileUpload1);
exit();
in the after delete event to see what values the fileupload component is storing at that time.
There are 4 places where the upload component stores filename info
->Value
->Text
->State[0]
->State[1]
If the filename data has been erased, then I suggest that you create an earlier event, store the file name in a global, then call that global variable in the afterdelete file event.
Regards,
Don A
|
 |
 |
|