Showing posts with label files. Show all posts
Showing posts with label files. Show all posts

Friday, July 1, 2016

Generating excel xls files

Here we generate excel files from php script. To begin we will need some main excel classes as following:
1. BIFFwriter.php (for writing BIFF (binary file format)
2. Format.php (for generating excel XF records)
3. OLEwriter.php (OLE stream for spreadsheet)
4. Parser.php (for parsing excel formula)
5. Workbook.php (for generating excel workbook)
6. Worksheet.php (for generating excel worksheet)

You may want to see some examples in which you can download with all the six files above. You can download them all here (48kb) !!.

There are also five example files included:
1. example1.php (creating first example in generating excel document and comments are also included)
2. example2.php (set and modify fonts and styles)
3. example3.php (set columns and rows)
4. example4.php (set page)
5. example5.php (apply formula)

Tuesday, June 28, 2016

Generating RTF Files cont

Instead of using RTFGen, we may also use another class namely rtfgenerator in which we can download from phpclasses.org or you can download it here (5kb)!!

After downloading, extract to your folder inside your web server and execute the index.html file and then write your sentences in the textarea provided and press the generate rtf button. That simple.

Monday, June 27, 2016

Upload Form PHP Script A PHP Script Which Will Enable You To Upload Files On Your Site

A very simple php script.Simple file upload form for your site.

Features:
  • Limit file types available for upload
  • Maximum file size validation
  • Can rename file after upload to avoid URL guessing
  • Log of uploads can be saved in MySql database. Log includes Filename, file size, IP of the user, date of upload
 Download Upload Form PHP Script

Wednesday, June 15, 2016

Creating PDF Files

Here we create pdf files from php scripts. We use ezpdf class. You can download it here (557kb)!! in which I bundled with some files of examples. I gave comments on those examples to understand some functions.
Below are some captures of the example scripts

For examples 1, 2a,and 2b we try to play with fonts and style like this:


For example 3a,3b, and 3c we practice with table like this:


For example 4, 5, and 6 we practice with image, setup page, and make columns:

Monday, May 23, 2016

Import and export data in databases to XML files

This class is meant to import and export data stored in SQL databases to XML files using the ADODB library.

It provides a function to export the data of SQL query result set to XML file.

It also provides another function that parses XML files that define the data of fields to be inserted as new rows of a table also specified in the XML files.

You can download these files (the class and the examples) from phpclass.org or here (8kb)

Included in the package are:
class.ADODB_XML.php Class Class mother

 class.xml.php    --    Class    -- Auxiliary class

 connection.php --  Aux. --  connection for ADOdb

 DB_TO_XML.php --  Example --  This example saves the data of the consultation in an file XML

 user.sql  --  Data  --  Script SQL

 usersxml.xml --  Data  --  XML for test

 XML_TO_DB.php --  Example --  This example saves the content of file XML in the table "users" of the Data base
 

Friday, May 13, 2016

PHP Download Scripts Two Free PHP Scripts Which Enable Users to Download Files from your Website

Today I am going to share two PHP Script which will be useful for all the Webmasters out there.This PHP Script will enable your visitors to Download various files (be it mp3,movies,zipped etc.) from your website.In short, this is a Download Script and its FREE!

1. Download Script 1

This Download Script works perfectly even when you need to download files from a Protected Directory.Besides this download script also uses Cache control which gives you an option to Open Files for Viewing Without Saving it on your Hard Drive.For example, in case of a text file, you can open the file to view its contents without saving the file on your Hard Disk.The Script is located below:
<?php

// place this code inside a php file and call it "download.php"
$path = $_SERVER[DOCUMENT_ROOT]."/path2file/"; // change the path to your websites document structure
$fullPath = $path.$_GET[download_file];

if ($fd = fopen ($fullPath, "r")) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
switch ($ext) {
case "pdf":
header("Content-type: application/pdf"); // add here more headers for different extensions like doc excel and more
header("Content-Disposition: attachment; filename="".$path_parts["basename"]."""); // use attachment to force a download
break;
default;
header("Content-type: application/octet-stream");
header("Content-Disposition: filename="".$path_parts["basename"].""");
}
header("Content-length: $fsize");
header("Cache-control: private"); //use this to open files directly
while(!feof($fd)) {
$buffer = fread($fd, 2048);
echo $buffer;
}
}
fclose ($fd);
exit;
// example: place this kind of link into the document where the file download is offered:
// <a href="download.php?download_file=some_file.pdf">Download here!</a>
?>

It must be noted that in the above example ,emphasis is made on pdf files.But you can always add more headers to suit your needs.

2. Download Script 2

This PHP Download script will not show any Confirmation message when the download will complete.
<?php
session_start();
/*
Note that this PHP Script does not show Confirmation message when the Download Completes.You can make the
required changes to suit your needs
*/
//You Can Change the URLs to suit your needs
$error=http://errorexample.com;
$filepath=/my/local/file/path/to/images/;
$getfile = basename ($getfile);

if (isset($_POST[downl_file]) && basename($_POST[downl_file]) == $_POST[downl_file]) {
$getfile = $_POST[downl_file];
$_SESSION[downloadfile] = $_POST[downl_file];

} else {
header("Location: $error");
exit;
}
if ($getfile) {
$path = $filepath . $getfile;
// check that it exists and is readable
if (file_exists($path) && is_readable($path)) {
// fetch the file size and send the respective headers

$size = filesize($path);
header(Content-Type: application/octet-stream);
header(Content-Length: . $size);
header(Content-Disposition: attachment; filename= . $getfile);
header(Content-Transfer-Encoding: binary);
// opens in read only mode
// Ignore error message
$file = @ fopen($path, r);
if ($file) {
// stream the file and exit the script once download is completed
fpassthru($file);

exit;

} else {
header("Location: $error");

}
} else {
header("Location: $error");
}
}
?>
Note that these two PHP Scripts are WORKING!, so you can begin using it straightaway.If you have any suggestions regarding the script please feel free to share it with us.Feel free to edit the above two scripts to suit your personal needs.

Subscribe to our blog and we will email you similar interesting scripts as soon as it is published.

Enjoy!

Thursday, May 12, 2016

Delete Uploaded Files From Folder using PHP and MySQL

This is my continuation post of how to upload and view files , In this post we will see that how to completely delete(remove) uploaded files from folder and MySql database table using PHP , you can delete any files pdf, mp3, image, video any...,when you upload any file it moves on particular folder, after delete  that database record data only deleted but files stay on same folder only it's not delete. So how to do let's see.


Read more »

Monday, May 2, 2016

Generating RTF Files

If we want to generate rtf files or may want to generate reports based on frt files we may need working with rtfgenerator class in which we can download from www.phpclasses.com. To see or learn how it works you may take look at some examples of scripts in which include the rtfgenerator files.
You can download it here (21 kb) !!

there are 3 files of examples:
1. example1.php
2. example2.php
3. example3.php
and 3 other files of rtf generator:
1. frtf.php containing main class to generate rtf files
2. param.inc.php used to set configuration of the class
3. rtfkeywords.inc.php containing all the keywords defined by RTF Specification version 1.7