User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,779 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,452 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 384 | Replies: 0
Reply
Join Date: Jul 2006
Posts: 155
Reputation: tefflox is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
tefflox's Avatar
tefflox tefflox is offline Offline
Junior Poster

Please help with my first upload script..

  #1  
May 7th, 2008
Hello, thanks for helping out.

I need to upload an image, mogrify it to three smaller instances and rename it.

thanks again.

if ($_FILES["file"]["error"] > 0)

echo "Error: " . $_FILES["file"]["error"]            .     "<br />";

else {

echo "Upload: "    . $_FILES["file"]["name"]         . "<br />";
echo "Type: "      . $_FILES["file"]["type"]         . "<br />";
echo "Size: "     . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file"]["tmp_name"]     . "<br/><br/>";
}




if (((     $_FILES["file"]["type"] == "image/gif"    )
|| ( $_FILES["file"]["type"] == "image/jpeg"   )
|| ( $_FILES["file"]["type"] == "image/pjpeg"  ))
&& ( $_FILES["file"]["size"] < 1620000         )) {

if ($_FILES["file"]["error"] > 0)

echo "Return Code: " . $_FILES["file"]["error"] . "<br />";

else {

echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
}
if (file_exists("admin_uploads/" . $_FILES["file"]["name"]))

echo $_FILES["file"]["name"] . " already exists. ";

else {

move_uploaded_file($_FILES["file"]["tmp_name"],
"admin_uploads/" . $_FILES["file"]["name"]);
echo "Stored in: " . "admin_uploads/" . $_FILES["file"]["name"];


/*
******  do triple mogrify and update inventory table ******/ 


$command = '/usr/bin/mogrify';

exec("cp /admin/admin_uploads/" . $_FILES["file"]["name"] . "/admin/admin_uploads/current-large.jpg");
exec("cp /admin/admin_uploads/current-large.jpg /admin/admin_uploads/current-mid.jpg");
exec("cp /admin/admin_uploads/current-mid.jpg /admin/admin_uploads/current-tn.jpg");									

$resize_large = $command . '-resize 600x450 current-large.jpg';
$resize_mid   = $command . '-resize 300x225 current-mid.jpg';
$resize_tn    = $command . '-resize 100x100 current-tn.jpg';


// remember to validate jpg upload

exec($resize_large);
exec($resize_mid);
exec($resize_tn);


}

}
else

echo "Invalid file";
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 4:54 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC