Heya - I hope to god someone can help, I've been trying to do this for weeks and every script I try just seems to hate me. Either that or I'm stupid.
Here's my script:
if (phpversion() > "4.0.6") {
$HTTP_POST_FILES = &$_FILES;
}
define("MAX_SIZE",300000000);
define("DESTINATION_FOLDER", "temp");
define("no_error", "file:///D|/Documents and Settings/My Documents/Web Pages/Future Innovation/ok.htm");
define("yes_error", "file:///D|/Documents and Settings/My Documents/Web Pages/Future Innovation/error.htm");
$_accepted_extensions_ = "";
if(strlen($_accepted_extensions_) > 0){
$_accepted_extensions_ = @explode(",",$_accepted_extensions_);
} else {
$_accepted_extensions_ = array();
}
$_file_ = $HTTP_POST_FILES['file'];
if(is_uploaded_file($_file_['tmp_name']) && $HTTP_POST_FILES['file']['error'] == 0){
$errStr = "";
$_name_ = $_file_['name'];
$_type_ = $_file_['type'];
$_tmp_name_ = $_file_['tmp_name'];
$_size_ = $_file_['size'];
if($_size_ > MAX_SIZE && MAX_SIZE > 0){
$errStr = "File troppo pesante";
}
$_ext_ = explode(".", $_name_);
$_ext_ = strtolower($_ext_[count($_ext_)-1]);
if(!in_array($_ext_, $_accepted_extensions_) && count($_accepted_extensions_) > 0){
$errStr = "Estensione non valida";
}
if(!is_dir(DESTINATION_FOLDER) && is_writeable(DESTINATION_FOLDER)){
$errStr = "Cartella di destinazione non valida";
}
if(empty($errStr)){
if(@copy($_tmp_name_,DESTINATION_FOLDER . "/" . $_name_)){
header("Location: " . no_error);
} else {
header("Location: " . yes_error);
}
} else {
header("Location: " . yes_error);
}
}
?>
And the error I get is:
Notice: Undefined index: file in g:\inetpub\wwwroot\futureinnovation\upload2.php on line 18
which is the line
$_file_ = $HTTP_POST_FILES['file'];
All I have on the page is a simple form, all the parameters seems to be defined correctly. The script is a plugin for Dreamweaver MX. Maybe it's just broke, I don't know. All I want to do is be able to upload MP3s to a folder!
Pls help!