hi,in my database photo field value, i have a default value set on the var cahar 255 : “photo_default_profil.png” ; of course, i put the photo file in the folder name like that “photo_default_profil.png”.when i add a new item in phpmaker, the default photo file is not considered (not displayed not pre-selected) . even, the default string “photo_default_profil.png” is ignored when i save the record.Best regards
first problem to fix that : i need to upload each time the photo_default_profil.png when i don’t have a photo for the people record i edit. (so i have to have it on my computer which is a problem when there are many users)second problem : when i upload many times the same “photo_default_profil.png” for missing photo of the people, phpmaker recread duplicate files photo_default_profil(1).png photo_default_profil(2).png photo_default_profil(3).png …etc.it would be good phpmaker can have a feature for “unique” and default image file for photo/file field.Here i posted the problem for photo field, but it is the same for pdf field. if i want to upload a blank default pfd form file, i 'll need to upload many times the same file …So the server got bigger and bigger on storage with same files…best regards
Perhaps this would help to rename multiple files: http://hkvforums.com/viewtopic.php?f=4&t=44480
thank you for the tip. it solved one part of the problem with the row_inserting_event :[code]
// Row Inserting event
function Row_Inserting($rsold, &$rsnew) {
// Enter your code here
// To cancel, set return value to FALSE
if ($rsnew[“etu_photo”]==“”) $rsnew[“etu_photo”]=“photo_default_profil.png”;
return TRUE;
}
[/code]but i don’t want the user can delete the default file (delete button near the upload field)
amiens80 wrote:
but i don’t want the user can delete the default file (delete button near the upload
field)Currently, there is no option to disable that delete button.
You may customize the template id=“template-download” in footer.php. (v2020) Also read the topic Server Events and Client Scripts > Page_Foot in the help file.
hi,the delete button does not delete the field, it deletes (erase in fact) the input field, so it is fine to let it here.i fixed the add behaviour with the default photo.but i can’t manage to fixe the update process with function Row_Updating($rsold, &$rsnew)there , i entered this php code :
if ($rsold[“etu_photo”]==“”) $rsnew[“etu_photo”]=“photo_default_profil.png”;
if ($rsnew[“etu_photo”]==“”) $rsnew[“etu_photo”]=“photo_default_profil.png”;i don’t know why, but when a record already got a real photo, then it is replaced by my default one too !
Just change all of your code above to:if ($rsold[“etu_photo”]==“” && $rsnew[“etu_photo”]==“”) $rsnew[“etu_photo”]=“photo_default_profil.png”;
mobhar wrote:
Just change all of your code above to:if ($rsold[“etu_photo”]==“” &&
$rsnew[“etu_photo”]==“”)
$rsnew[“etu_photo”]=“photo_default_profil.png”;it works
thank you…but when i use the little delete button (to clear the input field of photo file) and choose no other file, then the rsnew did not updated with the default photo but the blank…i have to go back and resave the item to have the default one.
Try this modified version:if ( ($rsold[“etu_photo”]==“” && $rsnew[“etu_photo”]==“”) || (empty($rsnew[“etu_photo”])) ) $rsnew[“etu_photo”]=“photo_default_profil.png”;
mobhar wrote:
Try this modified version:if ( ($rsold[“etu_photo”]==“” &&
$rsnew[“etu_photo”]==“”) ||
(empty($rsnew[“etu_photo”])) )
$rsnew[“etu_photo”]=“photo_default_profil.png”;hi,other problem. when there is a real photo, it is replaced by my default one !you see, this feature is tweakee ! that should be integrated into phpmaker
Put this in “Row_Updating” server eventif ( ($rsold[“etu_photo”]==“” && $rsnew[“etu_photo”]==“”) || ( !empty($rsold[“etu_photo”]) && empty($rsnew[“etu_photo”]) ) )
rsnew[“etu_photo”]=“photo_default_profil.png”;