hi got this problem. i have a script for uploading files with php but it doesn’t work I was told to put this code in
[B]if(isset($HTTP_POST_FILES[‘file’]) && $HTTP_POST_FILES[‘file’] != “”) {
$_file
}else{
$_file
}
which would replace this line
[B]$_file
the error I am getting is
[B]Notice: Undefined index: file in c:phpdev5wwwtmppw547ge9sp.php on line 18.
lin 18 is
[B]$_file
Here is the full script
<?php
// ———————————————
// Pure PHP Upload version 1.1
// ——————————————-
if (phpversion() > “4.0.6”) {
$HTTP_POST_FILES = &$_FILES;
}
define(“MAX_SIZE”,300000);
define(“DESTINATION_FOLDER”, “./uploads”);
define(“no_error”, “sucsess.php”);
define(“yes_error”, “faild.php”);
$_ = “”;
if(strlen($_) > 0){
$_ = _);
} else {
$_ = array();
}
$_ = $HTTP_POST_FILES[‘file’];
if(is_uploaded_file($_[‘tmp_name’]) && $HTTP_POST_FILES[‘file’][‘error’] == 0){
$errStr = “”;
$_ = $_[‘name’];
$_ = $_[‘type’];
$_ = $_[‘tmp_name’];
$_ = $_[‘size’];
if($_ > MAX_SIZE && MAX_SIZE > 0){
$errStr = “File troppo pesante”;
}
$_ = explode(“.”, $_);
$_ = strtolower($_[count($_)-1]);
if(!in_array($_, $_) && count($_) > 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($_,DESTINATION_FOLDER . “/” . $
header(“Location: ” . no_error);
} else {
header(“Location: ” . yes_error);
}
} else {
header(“Location: ” . yes_error);
}
}
?>
<html>
<head>
</head>
<body>
<form name=”form1″ enctype=”multipart/form-data” method=”post” action=””>
<input type=”file” name=”file”>
</form>
</body>
</html>
Please help
Thanks