View Single Post
Old 08-10-2006, 11:25 PM  
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Full code would then look something closer to this (Untested):
Code:
<?php

# Full path to uploads, end with forward slash
$target_path = "/path/to/uploads/";

if( !is_uploaded_file($_FILES['uploadedfile']['tmp_name']) ) {
	die("Invalid upload.");
}

$target_path = $target_path .$_FILES['uploadedfile']['tmp_name']; 

# Valid characters in filename are a-z, 0-9, or a dot
$tempfilename = preg_replace('/[^a-z0-9\.]+/i','',$_FILES['uploadedfile']['tmp_name']);
# Uncomment below if desiring a unique string filename instead
# $tempfilename = uniqid('upload-');

$target_path = $target_path . $tempfilename; 

if( move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path) ) {
    echo "The file ".$_FILES['uploadedfile']['tmp_name']." has been uploaded to: ".basename($target_path);
} else {
    echo "There was an error uploading the file, please try again!";
}

?>
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote