This topic is locked

PHPRunner deletes read-only files

7/18/2009 6:50:30 PM
PHPRunner General questions
K
KevinMillican author

I am storing images in a files directory.
I want the missing images to revert to showing a 'No Photo' image, so I have added an event to check whether the image filename is blank and if so, change it to none.gif
This works fine but there is one problem:

If the user uses the 'Delete' radio button, it deletes the none.gif file, even though I have set it to read-only.
Is there a good workaround to preserve the file when the user inadvertantly does this, and is this behaviour by design or a bug ?

J
Jane 7/20/2009

Hi,
you can just rename none.gif to the no_image.gif.

K
KevinMillican author 7/20/2009

Hi,

you can just rename none.gif to the no_image.gif.


That behaviour works when you are storing the image as a binary object within the database, but there is no attempt to display an image when storing images as files and the filename field is null.

J
Jane 7/21/2009

Kevin,
for images saved on the disc use custom format on the "View as" settings dialog on the Visual Editor tab.

Here is a sample:

if (!$value)

$value = "<img src=\"images/none.gif\">";

K
KevinMillican author 7/23/2009

Kevin,

for images saved on the disc use custom format on the "View as" settings dialog on the Visual Editor tab.

Here is a sample:


Thanks for that.

It was slightly more complicated than that for me. I used this for my thumbnails (a virtual field) ...
if ($value=="th_")

$value = "<img src=\"files/images/th_none.gif\">";

else

$value = "<img src=\"files/images/".$value."\">";
... and ...
if ($value=="")

$value = "<img width=100 border=0 src=\"files/images/none.gif\">";

else

$value = "<img width=100 border=0 src=\"files/images/".$value."\">";
... for the actual photos in the View page, and 'Views' I created where I need printer-quality instead of the thumbnails.
(I'm sure you realised this sort of adaptation would be required, but it may be helpful to anyone else following this thread)
Thanks again <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=42949&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />