RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1907 | Replies: 1 | Thread Tools  Display Modes
Reply
Join Date: Aug 2004
Location: Los Angeles
Posts: 347
Reputation: Ghost is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

How To Upload in PHP

  #1  
Sep 5th, 2005
Hi!

Does anyone know how to upload files? I already made the form.

Thanks!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: How To Upload in PHP

  #2  
Sep 5th, 2005
[php]$file = $_FILES["file"];
// set the file type you will allow to avoid abuse to your server
$accept = array('pdf','doc','xls','ppt','txt','zip');
if($file["size"] > 0) {
$file_name = basename($file["name"]);
$ext = substr($file_name, -3, 3);

// validate file
if ($file["size"] > 500000) {
echo "Filesize over 500 KB limit.<br>\n";
}
elseif(!in_array($ext, $accept)) {
echo "Invalid file format. <br>\n";
}
else {
// set folder path to which image uploaded
$uploaddir = "/foldername/";
//copy the file to some permanent location
if (move_uploaded_file($file['tmp_name'], $uploaddir.$file['name'])) {
echo $file['name']." uploaded.<br>\n";
}
else {
echo "Error found. Please try again. <br>\n";
}
}[/php]
Ecommerce-Web-Store.com Building Your e-Business.
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)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:40 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC