A Simple PHP Multi Uploader with rand() and time()

I think this would be the simplest file multi uploader to an specific location. It uses copy() for the upload method and add a random number based on time to avoid replacement of the files including same file name.

This is the approach:

The form for uploading:

<table width=”500″ border=”0″ align=”center” cellpadding=”0″ cellspacing=”1″ bgcolor=”#CCCCCC”>
<tr>
<form action=”multiple_upload_ac.php” method=”post” enctype=”multipart/form-data” name=”form1″ id=”form1″>
<td>
<table width=”100%” border=”0″ cellpadding=”3″ cellspacing=”1″ bgcolor=”#FFFFFF”>
<tr>
<td><strong>multiple Files Upload </strong></td>
</tr>
<tr>
<td>Select file
<input name=”ufile[]” type=”file” id=”ufile[]” size=”50″ /></td>
</tr>
<tr>
<td>Select file
<input name=”ufile[]” type=”file” id=”ufile[]” size=”50″ /></td>
</tr>
<tr>
<td>Select file
<input name=”ufile[]” type=”file” id=”ufile[]” size=”50″ /></td>
</tr>
<tr>
<td align=”center”><input type=”submit” name=”Submit” value=”Upload” /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
multi

The processor file:

<?php
//set where you want to store files
//in this example we keep file in folder upload
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
//”upload” folder should exist aleady

$path1a= “upload/”.$_FILES['ufile'][0];
$path2a= “upload/”.$_FILES['ufile'][1];
$path3a= “upload/”.$_FILES['ufile'][2];

//srand( microtime() * 1000000);
$num1 = rand(1,1000);
$num2 = rand(1000,2000);
$num3 = rand(2000,3000);
//echo(“Random Number:”.$num.”<br/>”);

$path1=$path1a.time().$num1.’_’.basename($_FILES['ufile']['name'][0]);

//add a random name with the base name
$path2=$path2a.time().$num2.’_’.basename($_FILES['ufile']['name'][1]);
$path3=$path3a.time().$num3.’_’.basename($_FILES['ufile']['name'][2]);

//copy file to where you want to store file
copy($_FILES['ufile']['tmp_name'][0], $path1);
copy($_FILES['ufile']['tmp_name'][1], $path2);
copy($_FILES['ufile']['tmp_name'][2], $path3);

//$_FILES['ufile']['name'] = file name
//$_FILES['ufile']['size'] = file size
//$_FILES['ufile']['type'] = type of file
echo “File Name :”.$_FILES['ufile']['name'][0].”<BR/>”;
echo “File Size :”.$_FILES['ufile']['size'][0].”<BR/>”;
echo “File Type :”.$_FILES['ufile']['type'][0].”<BR/>”;
echo “<img src=\”$path1\” width=\”150\” height=\”150\”>”;
echo “<P>”;

echo “File Name :”.$_FILES['ufile']['name'][1].”<BR/>”;
echo “File Size :”.$_FILES['ufile']['size'][1].”<BR/>”;
echo “File Type :”.$_FILES['ufile']['type'][1].”<BR/>”;
echo “<img src=\”$path2\” width=\”150\” height=\”150\”>”;
echo “<P>”;

echo “File Name :”.$_FILES['ufile']['name'][2].”<BR/>”;
echo “File Size :”.$_FILES['ufile']['size'][2].”<BR/>”;
echo “File Type :”.$_FILES['ufile']['type'][2].”<BR/>”;
echo “<img src=\”$path3\” width=\”150\” height=\”150\”>”;

///////////////////////////////////////////////////////

// Use this code to display the error or success.

$filesize1=$_FILES['ufile']['size'][0];
$filesize2=$_FILES['ufile']['size'][1];
$filesize3=$_FILES['ufile']['size'][2];

if($filesize1 && $filesize2 && $filesize3 != 0)
{
echo “We have recieved your files”;
}

else {
echo “ERROR…..”;
}

//////////////////////////////////////////////

// What files that have a problem? (if found)

if($filesize1==0) {
echo “There’re something error in your first file”;
echo “<BR />”;
}

if($filesize2==0) {
echo “There’re something error in your second file”;
echo “<BR />”;
}

if($filesize3==0) {
echo “There’re something error in your third file”;
echo “<BR />”;
}

?>

Published in:  on May 17, 2009 at 6:51 pm Comments (4)

My Recent Getafreelancer Projects

Recently i have done 2 projects on Get a Freelancer from which one is a complete but so simple website of a vaccination program and other was to create 5 simple HTML-CSS templates.

vaccine This is the Vaccination Site. I completed this project in two days and got paid $250.
ka

And below those 5 templates for which i got paid $80
ka
ka
ka
ka

Published in:  on April 22, 2009 at 3:29 am Leave a Comment

My First WordPress Theme!

Yesterday i made a wordpress theme which is my first work in theme based works. The theme is 100% widgets supported. It is two columns based and has fixed width. I named it RedHat because i used a redhat logo and Black+Red color in major in that theme.
You can see this theme in work.
Click the screenshot below.screenshot

Please don’t forget to comment about my silly job.

Published in:  on November 24, 2008 at 3:29 am Comments (4)

Authentication Module with E-mail & Image Verification!

I’ve built an authentication system which can be used as secured module in a registration form or in a suggestion box where there are probability of insertion of data by a robot script. By using the image verification fact no auto generated script can fill up a form. Other wise there is an e-mail verification fact by which the man who fill up the form giving his e-mail address should check up his inbox for the mail sent by the form.
The e-mail is sent with a link on which by clicking it executes a script for neccessary update in the database.


In this module when a user fill up the form then in database every data is inserted and in a filled named active ‘0′ is inserted. When the user clicks on the link sent to him by e-mail. It then executes another script page which then updates the value of active field into ‘1′.
Then you can verify a user by examining the value of his active field in database that ensures that he clicked on th link.
This can be used as module in any Webapp.

See the example: Register Login

You can download the source code from the ShareBox left of side of my site. named Auth.zip

Published in:  on August 1, 2008 at 5:29 pm Comments (1)

My 5th Semester Project!

I have launched my 5th semester project on the web for testing and further feedback. I was directed to make a web app for a garments shop. There are two types of use. Administrator can upload a product by specific privilege and customer can see required product or all product by searching with requirements. They also can by the product.

The address: My project

Published in:  on July 29, 2008 at 2:16 pm Leave a Comment

I’ve Launched my first Facebook Application using iFrame:

It is an interesting matter to have a facebook application built by own. There is enough restriction to use HTML code or using JS in that app. But adding this app in iframe mode you can place any kind of application you have made. You Application must be in your own hosting server. Facebook will just redirect to this location within there view.

To get started just go to the Developers link in your facebook account and you will get futher instruction.

My Application:
Name: Recent Event in RUET

To add this Application on your Facebook Profile :Get This: Click Here

Published in:  on May 28, 2008 at 5:04 am Leave a Comment

Another Power of Ajax! Instant Edit on View-Page

When a page is displayed with requested data from a database, then normally the data it contains can be edited or updated by getting the id of that form and by using that to update the form. Now, with the Ajax you can make a output page where you can edit the field of the form by just clicking on it and it will be saved to database instantly.

I’m unable to describe the benifit or beauty of this task. Just try it and make it more effective and do the JavaScript and be with Ajax. Example named insedit.zip

Published in:  on May 1, 2008 at 2:08 am Comments (2)

Feelings of Drag and Drop using Ajax-PHP-MySQL

Refference -Building Responsive Web Application by PACKT PUBLICATION

You Just try this example and feel the power of Ajax and the libraries just like Script.aculo.us , prototype.js . Recently, Web Application without attractive interface is not accepted to real users. So, use the maximum of Libraries and Frameworks.

 You can get this example in my Shared Box named dragdrop.zip

Published in:  on April 21, 2008 at 12:53 am Comments (1)

Simply Make Bangla Web App with Database Connectivity!

Created by Sagor Sugested by Nuhil

You can make a Web app using Bangla Interface simply by using one kind of Unicode Font write such as
Avro Keyboard. But there is a restriction. In the client PC , the page will not be shown properly if there does not exist any bangla font installed. So, you can give a link in that page to download a font.

You can also get the benifit of MySQL using simple Queries. Define the database and table datatype as utf8_general_ci  . Then simply write this two lines after DB cofiguration lines,

mysql_query(‘SET CHARACTER SET utf8′,$con);
mysql_query(“SET SESSION collation_connection=’utf8_general_ci’”,$con);

***Builder or User should use unicode writer.
Now you can do normal PHP-MySQL tasks in Bangla. Here is an example named Bangla.zip in my Share Box.

Published in:  on April 11, 2008 at 11:08 pm Comments (5)

Store your Source Code of page in Database and Rtrieve them on Request.

You can store any kind of code in database. Simply you have to choose BLOB  Datatype. For example LONGBLOB, MEDIUMBLOB etc. Using this datatype you can insert any data as binary such as image, codes, files etc in the same row of a corresponding id.
Here i’ve made a file named call_from_db.php in which there are a few lines to retrieve the original codes from DB and put them on this page. In template table, the main configuration of HTML tags are fixed. In content table codes are inserted in different columns. Finally in call_from_db.php page print them sequentially.

Download the example from the Share Box in the right side of this page. The file is named call_from_db.zip

Published in:  on April 2, 2008 at 4:03 pm Leave a Comment