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: -
<?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, '.'));
-
}
-
?>
-
2 3295
hi
you must add a form to the page and sumbit attritue of this form you must be add address of this file ,
$_FILES[NAME] , NAME is the name attribute of the file element in this form ,
in this script extension file is check, size of the file is checked ,... and otherwise any disobey this conditional file is uploaded and after upload path of the file is saved on the database
for more details , study chapter file upload in php
thanks alot
hi dana,
I intergrated my own upload script with the one that came with uploadify... it was the easiest way and because uploadify looks for certain vars it was a pain to use my complete own so i had to mix the two as simple as possible as well due to the fact that uploadify kept on messing up on me... below is the code i used, it's not the answer you are looking for as I wrote this for a social networking script... there really isn't much to explain apart from i upload to a temp folder change the image sizes then rename and move the images to the correct folder, the majority of it is still uploadify's standard script -
$userPhoto=mkdir('user/'.$userName.'/photos/'.$uploadID.'/', 0777);
-
$userTemp=mkdir('user/'.$userName.'/photos/'.$uploadID.'/tmp/', 0777);
-
$userThumb=mkdir('user/'.$userName.'/photos/'.$uploadID.'/tmp/t/', 0777);
-
$userMain=mkdir('user/'.$userName.'/photos/'.$uploadID.'/tmp/l/', 0777);
-
// specify file parameter name
-
$file_param_name = 'file';
-
// retrieve uploaded file name
-
$file_name = $_FILES[ $file_param_name ][ 'name' ];
-
// retrieve uploaded file path (temporary stored by php engine)
-
$source_file_path = $_FILES[ $file_param_name ][ 'tmp_name' ];
-
// construct target file path (desired location of uploaded file) -
-
// here we put to the web server document root (i.e. '/home/wwwroot')
-
// using user supplied file name
-
if (isset($userName)){
-
$target_file_path = "user/".$userName ."/photos/". $uploadID . "/tmp/l/" . $file_name;
-
} else {
-
$target_file_path = "user/" . $file_name;
-
}
-
// move uploaded file
-
if( move_uploaded_file( $source_file_path, $target_file_path ) ) {
-
$pathA = "user/".$userName ."/photos/". $uploadID . "/tmp/l/";
-
$pathB = "user/".$userName ."/photos/". $uploadID . "/tmp/t/";
-
if ($handle = opendir($pathA)) {
-
while (false !== ($file = readdir($handle))) {
-
if ($file != "." && $file != "..") {
-
if(!is_dir($file)){
-
$source = $pathA . $file;
-
$destination = $pathB . $file;
-
copy($source, $destination);
-
$details = array();
-
$details = getimagesize($source);
-
$detailsWidth = $details[0];
-
$detailsHeight = $details[1];
-
if ($detailsWidth > $detailsHeight){
-
$image = new SimpleImage();
-
$image->load("$source");
-
$image->resize(450,350);
-
$image->save("$source");
-
-
$image = new SimpleImage();
-
$image->load("$destination");
-
$image->resize(100,70);
-
$image->save("$destination");
-
}
-
elseif ($detailsHeight > $detailsWidth) {
-
$image = new SimpleImage();
-
$image->load("$source");
-
$image->resize(240,350);
-
$image->save("$source");
-
-
$image = new SimpleImage();
-
$image->load("$destination");
-
$image->resize(70,100);
-
$image->save("$destination");
-
}
-
}
-
}
-
-
} closedir($handle);
-
}
-
}
-
//variable used for the name of each file
-
$rnA = "user/".$userName ."/photos/". $uploadID . "/tmp/l/";
-
$rnB = "user/".$userName ."/photos/". $uploadID . "/";
-
$od = opendir($rnA);
-
while (false !== ($filename = readdir($od)))
-
{
-
//you can add any type of filenames you wish to skip (for instance Thumbs.db on windows)
-
if($filename != '.' && $filename != '..' && !is_dir($rnA.$filename))
-
{
-
//we give files a name - here we use increasing numbers for jpg files: '_'.$i++.'
-
if(rename($rnA.$filename, $rnB.$uploadID.zonedate('dmYH-i-s',true).'.jpg'))
-
echo '<br />';
-
}
-
}
-
closedir($od);
-
$rnC = "user/".$userName ."/photos/". $uploadID . "/tmp/t/";
-
$rnD = "user/".$userName ."/photos/". $uploadID . "/";
-
$odT = opendir($rnC);
-
while (false !== ($filename = readdir($odT)))
-
{
-
//you can add any type of filenames you wish to skip (for instance Thumbs.db on windows)
-
if($filename != '.' && $filename != '..' && !is_dir($rnC.$filename))
-
{
-
//we give files a name - here we use increasing numbers for jpg files: '_'.$i++.'
-
if(rename($rnC.$filename, $rnD.$uploadID.zonedate('dmYH-i-s',true).'_'.'b.jpg'))
-
echo '<br />';
-
}
-
}
-
closedir($odT);
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: lawrence |
last post by:
The following upload script seems to be working on PCs but not on
Macs. Can anyone imagine a reason why? Could there be something in the
form that turns in flawed data, or could IE on a Mac not...
|
by: Sielvja |
last post by:
Hi,
i've put an upload script on my site, hosted on a Windows NT Version
5.0 server.
When i try to upload something i get an error:
copy(files/file.txt): failed to open stream: Permission...
|
by: Willoughby Bridge |
last post by:
I am having trouble with a file upload script. Have tried a lot of
different methods and the problem boils down to the $_FILES variable not
being picked up. Below is a simple example of...
|
by: Chuck |
last post by:
Hi, can anyone provide or point me in the direction of a simple python
file upload script? I've got the HTML form part going but simply
putting the file in a directory on the server is what I'm...
|
by: brian.digipimp |
last post by:
So I wrote this upload script and I keep getting errors and can't get
it to work. I'm running ubuntu linux and here is my code:
<html>
<head>
<title>Upload</title>
</head>
<body>
<?php
|
by: grozanc |
last post by:
Hello,
I keep getting the following erorrs when trying to use a PHP/MYSQL upload script. Can anyone tell me what's causing this error? I'm not a programmer, just an MFA student working on his...
|
by: Ken1 |
last post by:
Hello,
Does anyone know of an easy to implement ajax upload script for php
which also has a progress bar. If possible I'd like it to be able to
remove already uploaded files and do minor...
|
by: camphor |
last post by:
hi,
I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
|
by: ll |
last post by:
I'm working with 'pure ASP upload' script which is designed to
redirect to an alert/error message, should
a file larger than the set limit be attempted to be uploaded. The
problem is that, while...
|
by: petershaman |
last post by:
Hi
I have a gorgeous flash image gallery, it would work perfectly fine but there's a small problem I can't upload anything thru it's upload script, since I'm getting an error 403. It's so because...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |