How to upload and show avatars in php? - php

Ok i want to load a Avatar with my users regso they can upload and make a profile page i have user reg and everything and im using a flat file in php?

You should consider integrating an existing avatar service such as Gravatar into your application. It might end up saving you and your users a bundle of time. From the Gravatar website:
A gravatar, or globally recognized avatar, is quite simply an image that follows you from site to site appearing beside your name when you do things. Avatars help identify your posts on blogs and web forums, so why not on any site?

Just treat the avatar upload like any photo upload. Create an avatar/image upload form to upload the image to your server in the profile page.

Related

Disable direct links to images on an expired or unpublished Blog Post on a custom PHP web application

I have a custom PHP simple Blogging web application where users can upload a blog post with photos and file attachments. They can unpublish their posts or set it to expire on a certain future datetime.
When I load the blog post on my website, say mydomain.com/post/100. I am showing a gallery of uploaded photos.. they are loaded via direct links for example mydomain.com/images/photo1.jpg etc. I am also showing file attachments and they are linked via direct links like mydomain.com/files/file1pdf etc.
When the post expires or intentionally unpublished, these direct links are still loading the photos and files.
So, to hide the file URLs, I have a ‘viewscript’ instead .. I am obfuscating the attached file link to mydomain.com/viewfile/xyz123 which the server code links to the specific post and checks if it is published and not expired and then downloads the file to the reader’s browser. This works for files. And on each click to the link.. or a direct access to the file, it is a single database query to check if the Post is still valid.
How do I do this for Images / Photos uploaded to the Post? I can do the same ‘viewscript’ .. but that means making a call to the database for each photo that is uploaded to the Post. I would like to disable direct link access to photos uploaded to a Blog post that is unpublished or expired.
Any suggestions or ideas? Thank you.

How to Upload images in the Admin Domain, and Save them in images folder in another domain (blog)?

Here is my problem, I have two domain names, lets say, x.com (users domain) and y.com (admin domain). They are using the same database.
I upload everything from the admin website and save in the common database, where the other site, x.com is fetching from.
My problem comes when am uploading images to be used by x.com Here is what I want to do, I want to upload images in the admin website, save the image in the images folder in the other site. and save the link to the database. The link is saving correctly but the image is not uploaded.
Is what am trying to do possible? And if yes, how can I achieve that?
Your help will be highly appreciated.
Thanks in advance.

Found some 404s for image files in statistis

I am running a website in which I generate dynamic images for users. Initially, I was saving all the images generated forever so that I can use those images when required to be shown again but since recently I started getting some decent traffic, so I thought instead of saving and reusing the images I should generate them again when they need to be shown again.
Now what I am doing is: I have created a temp folder and I save every image in that temp folder and show it to user. And when this image is required to be shown again, I just re-create that image instead of using this temp image. And temp folder is now emptied at sometime daily.
But now I have started getting 404s in my error logs for the images. I am not getting that from where I am getting those 404s since I myself tried deleting image from tmp and then revisited that page. The image was re-created and was shown properly. I am badly stuck at this. One thing I would like you to tell is that I am allowing user to share those result-pages(with images) on social networks.
So it is like:
I create one image in tmp and show it on some result.php page. I
also put the image's link in og meta tag so that it can be properly
identified by social networks while sharing.
If somebody visits result.php page again, then it shows image again. However, if image is not available(i.e. deleted as daily
job), then it recreates it first, saves at that location and then
shows the page.
I am getting 404s for .jpg image files in error log.
On debugging it more, I found that these 404s are there because of access to images from Facebook IPs. The IPs from which 404s are detected are like: 66.220.158.119, 173.252.101.116, etc. On some googling, I founf that these IPs are allocated to Facebook.
So it means: facebook bot is accessing the images because these links were earlier shared on facebook via facebook share. Can someone please tell me is there any harm if later(say after 1 day of sharing), if facebook does not find the image anymore on my server? Will it not show anymore on shared link on facebook also?

How to make a visual space e.g. like an album & upload pictures to a website?

I want to upload my pictures on my web site. The way I want to do is like there appear photo albums like images on my web page that contain my pictures. How do I do that?
Make an upload form, and store the uploaded files (filesystem and/or database). Then display them to the user.
Basic upload form example from w3schools

Using Flickr to Enable Images on a Site

Has anyone had success using Flickr to embed images that users can upload to my site, but that are hosted on Flickr?
Is something like this possible?
Thanks,
Alex
There is a flikr upload API:
http://www.flickr.com/services/api/upload.api.html
Have them upload their photos to your site, you can crop it or re-size it programatically with GD or imagemagick as needed, then use the flikr upload API to put it on your flickr account, then delete the original to save space, then embed it on the site.
This will save space for you. While also preventing your users from needing to get an account on another site, or having to leave your site to post photos, or figuring out how to link them back.

Categories