Search This Blog

Sunday, December 15, 2013

jQuery HTML5 File Upload with Bar Progress

Here is how you can implement drag and drop multiple file upload with native JavaScript. No plugins needed. Just plain old new HTML5. Again there is a working demo. You will need FireFox 3.6 to test it. Full source code can be at GitHub.

Demo   Download

html5 file upload 04


















Continue Reading...

jQuery Upload Multiple Files

Continue Reading...

HTML5 drag & drop API

Dragging and dropping files from your desktop to a browser is one of the ultimate goals for web application integration.
html5 upload file 08
Continue Reading...

HTML5 File and Folder Upload Control

 Get started fast with SlickUpload and be ready to scale up to advanced functionality when you need it.

html5 upload file 05
                                                         Demo   Download
Continue Reading...

Multiple File Upload using HTML5

As a response to a reported bug where Chrome was taking ages to load up a flash multiple-file uploader, I’ve updated KFM to use HTML5′s multiple-file input box where possible.

html5 upload file 06

                                                        Demo   |   Download
                 

Continue Reading...

Ajax Uploading With HTML5 File api

Prior to HTML5 and its File API, getting media from a user was a somewhat sordid affair.

html5 upload file 09  


Continue Reading...

HTML5 Multiple File Upload Plugin with progress-bar


This plugin uses XHR for uploading multiple files with progress-bar in FF3.6+, Safari4+, Chrome and falls back to hidden iframe based upload in other browsers, providing good user experience everywhere.

html5 upload file 07
                                           Demo  |   Download

Continue Reading...

Friday, December 13, 2013

How to Build Shopping Cart w/ Checkout in PHP

Download Script

I just rewrite the code included in this post to fix minor problem encounter by other PHP programmers who can’t run the shopping cart.
The code is taken from this link: http://www.qualitycodes.com/tutorial.php?articleid=25&title=Tutorial-Building-a-shopping-cart-in-PHP.
As you may have noticed, a lot of programmers are screaming for help on how to fix some bugs on this tutorial. Since I cannot upload the code in the said website, I decided to post it here. Still credit goes to “Richard Clark”.
Changes on the code are following:
  1. Change “<?” to “<?php” to handle php correctly. Some old program still uses “<?” to run PHP code. However, PHP 5 is not stricter and requires you to use php after <?, unless you configure Apache to allow such a shorthand support.
  2. Add echo command instead of equal (=) sign.
Note: If you run the code prior to downloading this code, make sure to clear your browser cache.

Continue Reading...

Create a Zip File Using PHP


Creating .ZIP archives using PHP can be just as simple as creating them on your desktop. PHP's ZIP class provides all the functionality you need! To make the process a bit faster for you, I've coded a simple create_zip function for you to use on your projects.

The PHP

/* creates a compressed zip file */
function create_zip($files = array(),$destination = '',$overwrite = false) {
	//if the zip file already exists and overwrite is false, return false
	if(file_exists($destination) && !$overwrite) { return false; }
	//vars
	$valid_files = array();
	//if files were passed in...
	if(is_array($files)) {
		//cycle through each file
		foreach($files as $file) {
			//make sure the file exists
			if(file_exists($file)) {
				$valid_files[] = $file;
			}
		}
	}
	//if we have good files...
	if(count($valid_files)) {
		//create the archive
		$zip = new ZipArchive();
		if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
			return false;
		}
		//add the files
		foreach($valid_files as $file) {
			$zip->addFile($file,$file);
		}
		//debug
		//echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status;
		
		//close the zip -- done!
		$zip->close();
		
		//check to make sure the file exists
		return file_exists($destination);
	}
	else
	{
		return false;
	}
}

Sample Usage

$files_to_zip = array(
	'preload-images/1.jpg',
	'preload-images/2.jpg',
	'preload-images/5.jpg',
	'kwicks/ringo.gif',
	'rod.jpg',
	'reddit.gif'
);
//if true, good; if false, zip creation failed
$result = create_zip($files_to_zip,'my-archive.zip');
The function accepts an array of files, the name of the destination files, and whether or not you'd like the destination file to be overwritten if a file of the same name exists. The function returns true if the file was created, false if the process runs into any problems.
Continue Reading...

Creating ZIP File with PHP

This post helps you to create a ZIP file using PHP, Arun had coded a few lines of script that system converts the selected files into ZIP file format. It is useful for ecommerce web projects like selling PDFs, Images and Docs ect, use can choose files and download it into compressed format. Take a look at this live demo.

Download Script     Live Demo


HTML Code
Form contains list of files with input type checkbox name files[]. 
<form name="zips" method="post">

<input type="checkbox" name="files[]" value="flowers.jpg" />
<img src="files/image.png" />
flowers.jpg

<input type="checkbox" name="files[]" value="fun.jpg" />
<img src="files/image.png" />
fun.jpg

<input type="checkbox" name="files[]" value="9lessons.docx" />
<img src="files/doc.png"   />
9lessons.docx
........
<input type="submit" name="createpdf" value="Download as ZIP" />&nbsp;
<input type="reset" name="reset"  value="Reset" />
</form>

PHP Code
Contains PHP code covert the selected files into ZIP file format.
<?php
$error = ""; //error holder
if(isset($_POST['createpdf']))
{
$post = $_POST; 
$file_folder = "files/"; // folder to load files
if(extension_loaded('zip'))
{ 
// Checking ZIP extension is available
if(isset($post['files']) and count($post['files']) > 0)
{ 
// Checking files are selected
$zip = new ZipArchive(); // Load zip library 
$zip_name = time().".zip"; // Zip name
if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE)
{ 
 // Opening zip file to load files
$error .= "* Sorry ZIP creation failed at this time";
}
foreach($post['files'] as $file)
{ 
$zip->addFile($file_folder.$file); // Adding files into zip
}
$zip->close();
if(file_exists($zip_name))
{
// push to download the zip
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zip_name.'"');
readfile($zip_name);
// remove zip file is exists in temp path
unlink($zip_name);
}

}
else
$error .= "* Please select file to zip ";
}
else
$error .= "* You dont have ZIP extension";
}
?>


Continue Reading...