Page 1 of 1

[SOLVED] Desktop short cut for a webpage

Posted: Wed Jul 13, 2011 5:14 am
by iijb
Hi all,
I have a webpage in which there is an image which when drag to desktop , should make a desktop short cut for the webpage. Is that possible. Please help me out.

Thanks in advance
iijb

Re: Desktop short cut for a webpage

Posted: Wed Jul 13, 2011 8:28 am
by edziffel
Never heard of making a short cut like that. Depending on the browser and OS you use, you can sometimes drag the URL to the desktop, Why not just us the favorites or book mark function of your browser?

Re: Desktop short cut for a webpage

Posted: Wed Jul 13, 2011 12:22 pm
by Pazuzu156
Simple, right click the desktop, and name it 'My Page.url'

In the file type:

Code: Select all

[InternetShortcut]
URL=http://www.mycompany.com
Save it, there you go :)

Desktop short cut for a webpage

Posted: Wed Jul 13, 2011 11:38 pm
by iijb
Hi,
Thanks Pazuzu156 that is what I need.

Thanks all
iijb

Re: Desktop short cut for a webpage

Posted: Thu Jul 14, 2011 5:56 pm
by Pazuzu156
If you wanted to do this with php, you could do this:

Code: Select all

<?php

// Create function and use a parameter for the url you will be using
function create_icon($url) {
	$filename = "./my_icon.url"; // make variable with the filename you will be using to be created
	
	/* make variable to have at the top,
	* this is to keep the file from messing up with
	* way the file has to be created*/
	$sc = '[InternetShortcut]';
	
	// check if $filename exists
	if(!file_exists($filename)) {
		file_put_contents($filename, $sc."\nURL=".$url); // if not, create the file, and place the content inside
	} else {
		file_put_contents($filename, $sc."\nURL=".$url); // if it does, do the same as if it doesn't exist
	}
}

// call up the function, use the url as the parameter
create_icon('http://www.domain.com');
?>
With the page order, I've played with this code, and if you don't do it like that, it messes up.

Re: Desktop short cut for a webpage

Posted: Mon Jul 18, 2011 4:25 am
by iijb
Hi,
I created the icon in the same folder of php script.
But there comes another problem for me. I have to get the Desktop path of the client machine for creating icon in desktop. How to get the desktop path using php. Also can we create a file in user's desktop. Please help.
Thanks again
iijb

Re: Desktop short cut for a webpage

Posted: Tue Jul 19, 2011 2:15 am
by Pazuzu156
I'm sorry to say you cannot get to the desktop path using PHP, and even if you could that would be a MAJOR security hole in your site not to mention people turning you in for hacking and whatnot. My suggestion to you is have a link, and when they click the link that it will use the function to create the file for them on download, but it would be temporary and deleted once obtained. If you need input on that I could made up a drafted code for you after class tomorrow.

Re: Desktop short cut for a webpage

Posted: Wed Jul 20, 2011 12:42 am
by iijb
Hi,
Thanks Pazuzu156 for your reply. I have made download shortcut as you told.

Thanks
iijb

Re: Desktop short cut for a webpage

Posted: Wed Jul 20, 2011 12:44 am
by Pazuzu156
Anytime man, glad I could help.