<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("#upload").bind("click", function () {
if (typeof ($("#fileUpload")[0].files) != "undefined") {
var size = parseFloat($("#fileUpload")[0].files[0].size / 102400).toFixed(2);
alert(size + " KB.");
} else {
alert("This browser does not support HTML5.");
}
});
});
</script>
</head>
<body>
<form method="post" name="f1" enctype="multipart/form-data">
IMAGE<input type="file" name="file" id="fileUpload" />
<input type="submit" name="btnadd" id="upload" value="ADD" />
</form>
<?php
include('connection.php');
if(isset($_POST['btnadd']))
{
echo $file=$_FILES['file']['name'];
$rand=rand(1,1555555);
$img=$rand.$file;
move_uploaded_file($_FILES['file']['tmp_name'],"img1/".$img);
if ((($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/jpeg"))){
//PHP Image Uploading Code
$sql=mysql_query("insert into img values('','$img')");
if(!$sql)
{
echo mysql_error();
}
else
{
echo "Done";
}
}
else
{
echo "invalid";
}
}
?>
<script type="text/javascript">
$(function () {
$("#upload").bind("click", function () {
if (typeof ($("#fileUpload")[0].files) != "undefined") {
var size = parseFloat($("#fileUpload")[0].files[0].size / 102400).toFixed(2);
alert(size + " KB.");
} else {
alert("This browser does not support HTML5.");
}
});
});
</script>
</head>
<body>
<form method="post" name="f1" enctype="multipart/form-data">
IMAGE<input type="file" name="file" id="fileUpload" />
<input type="submit" name="btnadd" id="upload" value="ADD" />
</form>
<?php
include('connection.php');
if(isset($_POST['btnadd']))
{
echo $file=$_FILES['file']['name'];
$rand=rand(1,1555555);
$img=$rand.$file;
move_uploaded_file($_FILES['file']['tmp_name'],"img1/".$img);
if ((($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/jpeg"))){
//PHP Image Uploading Code
$sql=mysql_query("insert into img values('','$img')");
if(!$sql)
{
echo mysql_error();
}
else
{
echo "Done";
}
}
else
{
echo "invalid";
}
}
?>
No comments:
Post a Comment