-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
2,502 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- phpMyAdmin SQL Dump | ||
-- version 3.2.0.1 | ||
-- http://www.phpmyadmin.net | ||
-- | ||
-- Host: localhost | ||
-- Generation Time: Dec 17, 2014 at 04:27 AM | ||
-- Server version: 5.1.36 | ||
-- PHP Version: 5.3.0 | ||
|
||
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; | ||
|
||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8 */; | ||
|
||
-- | ||
-- Database: `dbtuts` | ||
-- | ||
|
||
-- -------------------------------------------------------- | ||
|
||
-- | ||
-- Table structure for table `tbl_uploads` | ||
-- | ||
|
||
CREATE TABLE IF NOT EXISTS `tbl_uploads` ( | ||
`id` int(10) NOT NULL AUTO_INCREMENT, | ||
`file` varchar(100) NOT NULL, | ||
`type` varchar(30) NOT NULL, | ||
`size` int(11) NOT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; | ||
|
||
-- | ||
-- Dumping data for table `tbl_uploads` | ||
-- | ||
|
||
INSERT INTO `tbl_uploads` (`id`, `file`, `type`, `size`) VALUES | ||
(1, '70455-(r)11d.jpg', 'image/jpeg', 19), | ||
(2, '77190-3d-glass-green-effect.jpg', 'image/jpeg', 249); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
include_once 'dbconnect.php'; | ||
?> | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<title>File Uploading With PHP and MySql</title> | ||
<link rel="stylesheet" href="upload.css" type="text/css" /> | ||
</head> | ||
<body> | ||
<div id="header"> | ||
<label>File Uploading</label> | ||
</div> | ||
<div id="body"> | ||
<form action="upload.php" method="post" enctype="multipart/form-data"> | ||
<input type="file" name="file" /> | ||
<button type="submit" name="btn-upload">upload</button> | ||
</form> | ||
<br /><br /> | ||
<?php | ||
if(isset($_GET['success'])) | ||
{ | ||
?> | ||
<label>File Uploaded Successfully... <a href="view.php">click here to view file.</a></label> | ||
<?php | ||
} | ||
else if(isset($_GET['fail'])) | ||
{ | ||
?> | ||
<label>Problem While File Uploading !</label> | ||
<?php | ||
} | ||
else | ||
{ | ||
?> | ||
<label>Try to upload any files(PDF, DOC, EXE, VIDEO, MP3, ZIP,etc...)</label> | ||
<?php | ||
} | ||
?> | ||
</div> | ||
<div id="footer"> | ||
|
||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@charset "utf-8"; | ||
/* CSS Document */ | ||
|
||
* | ||
{ | ||
padding:0; | ||
margin:0; | ||
} | ||
body | ||
{ | ||
background:#fff; | ||
font-family:Georgia, "Times New Roman", Times, serif; | ||
text-align:center; | ||
} | ||
#header | ||
{ | ||
background:#00a2d1; | ||
width:100%; | ||
height:50px; | ||
color:#fff; | ||
font-size:36px; | ||
font-family:Verdana, Geneva, sans-serif; | ||
} | ||
#body | ||
{ | ||
margin-top:100px; | ||
} | ||
#body table | ||
{ | ||
margin:0 auto; | ||
position:relative; | ||
bottom:50px; | ||
} | ||
table td,th | ||
{ | ||
padding:20px; | ||
border: solid #9fa8b0 1px; | ||
border-collapse:collapse; | ||
} | ||
#footer | ||
{ | ||
text-align:center; | ||
position:absolute; | ||
left:0; | ||
right:0; | ||
margin:0 auto; | ||
bottom:50px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
include_once 'dbconnect.php'; | ||
if(isset($_POST['btn-upload'])) | ||
{ | ||
|
||
$file = rand(1000,100000)."-".$_FILES['file']['name']; | ||
$file_loc = $_FILES['file']['tmp_name']; | ||
$file_size = $_FILES['file']['size']; | ||
$file_type = $_FILES['file']['type']; | ||
$folder="uploads/"; | ||
|
||
// new file size in KB | ||
$new_size = $file_size/1024; | ||
// new file size in KB | ||
|
||
// make file name in lower case | ||
$new_file_name = strtolower($file); | ||
// make file name in lower case | ||
|
||
$final_file=str_replace(' ','-',$new_file_name); | ||
|
||
if(move_uploaded_file($file_loc,$folder.$final_file)) | ||
{ | ||
$sql="INSERT INTO tbl_uploads(file,type,size) VALUES('$final_file','$file_type','$new_size')"; | ||
mysql_query($sql); | ||
?> | ||
<script> | ||
alert('successfully uploaded'); | ||
window.location.href='file.php?success'; | ||
</script> | ||
<?php | ||
} | ||
else | ||
{ | ||
?> | ||
<script> | ||
alert('error while uploading file'); | ||
window.location.href='file.php?fail'; | ||
</script> | ||
<?php | ||
} | ||
} | ||
?> |
Oops, something went wrong.