I was just wondering if you ever figured out how to use your own upload.php script with uploadify? If so, could you explain how you got it to work? here is the script I would like to use with uploadify:
Code:
<?php
if (isset($_POST['upload'])) {
$con = mysql_connect("localhost", "sbslogin", "sbsdatab@53!") or die("cannot connect");
mysql_select_db("sbsdat", $con) or die("cannot select DB");
$img = $_FILES["image"]["name"];
foreach ($img as $key => $value) {
$name = $_FILES["image"]["name"][$key];
$tname = $_FILES["image"]["tmp_name"][$key];
$size = $_FILES["image"]["size"][$key];
$oext = getExtention($name);
$ext = strtolower($oext);
$base_name = "uploads/".getBaseName($name).".$ext";
$whois = $_SERVER['REMOTE_ADDR'];
if ($ext == "jpg" || $ext == "jpeg" || $ext == "bmp" || $ext == "gif") {
if ($size < 1024 * 1024) {
if (file_exists("uploads/" . $name)) {
move_uploaded_file($tname, "uploads/" . $name);
$result = 1;
//list($width, $height) = getimagesize("uploads/" . $name);
$qry = "select id from img where img_base_name='$base_name' and img_ext='$ext'";
$res = mysql_fetch_array(mysql_query($qry));
$id = $res['id'];
$qry = "UPDATE pictures SET path='$base_name', type='$ext', size='$size', date=NOW() where id=$id";
mysql_query($qry);
?><div style="float:right; text-align:left; width:400px;"><?php echo "Image '$name' <font color='blue'>updated</font><br />";
} else {
move_uploaded_file($tname, "uploads/" . $name);
$result = 1;
//list($width, $height) = getimagesize("uploads/" . $name);
$qry = "INSERT INTO pictures(id, path, type, size, email, whois, date) VALUES ('', '$base_name', '$ext', '$size', 'd.schuett@gmail.com', '$whois', NOW())";
mysql_query($qry, $con);
//Error Checking off by default. Uncomment if you run into problems.
//mysql_error();
//print_r($qry);
?><div style="float:right; text-align:left; width:400px;"><?php echo "Image '$name' <font color='green'>uploaded</font><br />";
}
} else {
?><div style="float:right; text-align:left width:400px;"><?php echo "<font color='red'><B>Image size excedded.<br />File size should be less than 1Mb</B></font><br />";
}
} else {
?><div style="float:right; text-align:left; width:400px;"><?php echo "<font color='red'><B>Invalid file extention '.$oext'</B></font><br />";
}
}
}
function getExtention($image_name)
{
return substr($image_name, strrpos($image_name, '.') + 1);
}
function getBaseName($image_name)
{
return substr($image_name, 0, strrpos($image_name, '.'));
}
?>
Comment