Please support our PHP advertiser: Lunarpages PHP Web Hosting
![]() |
•
•
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation:
Rep Power: 4
Solved Threads: 6
[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]
// 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.
![]() |
Similar Threads
Other Threads in the PHP Forum
- Barcode integration with PHP (PHP)
- how to retrive image file from mysql databse using php (PHP)
- php uploader script (PHP)
- PHP chat help (PHP)
- upload images and store the location in a database (PHP)
- Please help!!! Upload script.. (PHP)
- Help ! I need help starting up on Php ! (PHP)
Other Threads in the PHP Forum
- Previous Thread: Ecommerce Store Directory
- Next Thread: How To Create A Free Web Host
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode