Create Image/pdf/screenshot of webpage on click of a button - php

I have looked a for a way of allowing a user to click a button that will allow them to save an image or pdf of the current page. The page always chnages and relys on user input, based on this , sequences are returned , colored in different ways. So any way that will allow the user to take a screenshot and download it or save page as image , via a button or link. Can anyone help??

That's not a just like "add the button", you'll need many lines of code on the server-side if you'll decide to do it on your own.
If you really want to add the button only, I'd suggest to use AddThis for this task, it offers hundreds of possibilites, also online PDF generating, sharing by e-mail, support for social network sites, etc etc

Related

Upload multiple files while navigating other pages - howto?

I'm creating a website and I'd like to allow users to upload multiple files while they navigate the website.
When the upload completes, it would be nice to have a Javascipt event triggered, to allow the user to specify additional info related to the uploaded files (eg. photo location, tags, etc)
anyway, the required features are:
multiple files allowed for a single upload operation
display an optional progress indicator (at least in the "x of y files uploaded" fashion)
doing it without tying the users to a single page
How can I implement these features?
Any suggestion is greatly appreciated!
Edit
In the event of using a popup window to handle uploads, how can I:
inform the user (on the "master" page) that the upload has completed, or that there have been errors?
(more important) pass the $_FILES array to the popup window? I'd like the user to be able to click "upload" on the main window, or anyway to make the upload start from the main window (eg dragging and dropping files on the main window).
Since navigating the site will switch pages and it's unlikely that there's a full ajax navigation on your site, maybe it could help to somehow upload the files in a second popup window. Not sure how (if) it could be implemented, though, but since you need to upload multiple files at a time I'm afraid you're bound to use flash.
EDIT
So the solution could look like this:
When a user clicks a "select files" button you pop out a new window where he'll be able to actually select files (via flash if multifile upload is necessary). And to notify of upload progress use postMessage. Though postMessage isn't going to work in IE in this case, but probably you could somehow send the message to the server and from the server back to the page.
Another crazy idea is not to use a popup window, but let the user select the files on the page she was first, but once the user selects the files make all the links on the page target=_blank to make any subsequent navigation happen in another tab. I know it's hacky and not exactly user-friendly, but probably could help.
In any case I would inform the user beforehand that a new window will appear in both scenarios.
EDIT2
And an even crazier idea. When the user selects the files and clicks a link create an iframe which will cover the whole page and hide the original page beneath it and make the links open in the iframe. But it looks even more hackish and it seems you'll have much trouble with it.

Capturing the image view count on click while using jquery fancybox

does anyone have an idea on how I could capture the image id when a user clicks the next / previous button in Fancybox? I like how Fancybox changes depending on the size of the image so I prefer to use this over some of the other galleries that I have seen. Has anyone successfully done this? The site is in PHP.
The general idea would be to "proxy" your images by a PHP script.
This script would:
add 1 to the view count of the image
serves the image to the browser (instead of serving an HTML page as usual)
You would then update the src attribute of your pictures img tag :
<img src="mypicture.png"/>
would become
<img src="view_picture.php?picture=1"/>
Note that you must be careful and not authorize a filename in the picture parameter and/or carrefully check that the user is not trying to see a file that you don't want to show him (think view_picture.php?picture=../.htpasswd )
Consider using a general website analytics software, like Piwik. This will give you additional insights on you visitors and their actions on your site, rather than a simple image view counter.
I am running a site that uses Fancybox and Piwik, all image views through Fancybox will automatically show up in the Downloads section of Piwik reports without any additional configuration.
But you could easily customize this through Fancybox's onComplete callback and Piwik's trackPageView(). See Piwik Javascript API and Fancybox API for details.

Is this a good practice to avoid popup content displayed in a new tab or window?

I have pages with photo thumbnails, let's say the script is thumbnails.php. Each icon has a link to popup.php?id=nnn that opens in a pop-up window to display a larger image and some info.
I don't want a user going directly to domain.com/popup.php?id=nnn to get the popup small content in a whole window or tab.
So this script first checks if the referrer is the page containing the thumbnails.
If not, descrption.php?id=nnn is opened. This page is designed to fit a regular screen with extended info.
I did in this way mainly thinking in web crawlers.
Is this a good practice?
Many projects that I have worked on over the last 18 months have gone away from opening new windows or tabs altogether. Instead they use the Jquery Dialog (modal mode) to display images, html descriptions, or other attribute information.
This allows the user to stay on the same page without the risk of causing them to bounce if they accidentally close the wrong window or tab, or they just forget to go back to your site via the original window.

How to save a CSS image on server with PHP

I want to make a button generator with javascript in my site, something like this http://css-tricks.com/examples/ButtonMaker/ .
But I want to add a save button too, so that the user will be able to save the button image he creates. I want to save the image in my server with PHP if possible.
Does anyone have an idea, of what should I really read or search for?
Thanks in advance
The button in the example generator is rendered by your browser. It is just a button element which is styled. I don't think you can easily save it using php.
What you could do is create a button generator that accepts parameters and then renders the image serverside (using php) and sends it to the browser for displaying. This rendered image can then easily be saved.
The link you've provided just defines the CSS for the element - you just eed to send this back to the server - via a form or ajax.
One approach would be to send the css settings to your server and execute an html renderer which somehow allows you to save a screenshot of the button.
Googling for "html renderer" yields several results, but I can't tell whether any of them offers an API that allows you to easily save images of desired elements.
(Of course, Firefox and Chrome all count as html renderers too).
In the worst scenario, using my approach, you'd have to render the button server side, take an screenshot and use some algorithm to find and cut the button from the screenshot.
I'd say this is a complicated approach overall. I'd go with what Iljaas' says.

Saving videos intended to play using video embedding

In my website the users need to be able to enter the embed code( from youtube) in a textbox and when they click a submit button the videos should be displayed in the webpage. If a user selects an embed code , paste it, then video will be displayed in aparticular block say Block A in webpage. And now again if they want another video to be displayed in same webpage and it should be displayed in a block B, The problem when I load the page , the last video will be displayed in both the blocks A and B. So some sort of saving mechanism may be required?
You have to save embedded code in database corresponding to user id. Fetch from database to display on page.

Categories