Reputation: 5747
I have a website where the users can upload an image. However, before they upload one, on registering I want a standard image to be put in the directory. Almost a placeholder image.
How do I get about writing PHP that would take a copy of a file and put it into a different directory when a user reigsters?
Upvotes: 0
Views: 224
Reputation: 9078
You can work with a single placeholder image, and use that in case there isn't an uploaded image from the user. Example:
<php
$user_image = 'path/to/file.jpg';
if (file_exists($user_image)) {
echo '<img src="'.$user_image.'" alt="" />';
} else {
echo '<img src="path/to/placeholder.jpg" alt="" />';
}
?>
Upvotes: 2