i'm working with postnuke.& trying to upload something from postnuke(infact i have added some code for upload-easy uploads form bealers ..) my code is below given..
now when i include the upload pgm call the function as upload($file_up) where file_up is the name of my field in html
(<input type=file name=file_up>)
i get an error like
warning:wrong datatype for second argument in call to in_array in upload.php line no 71.
& the file u have tried to upload is not allowed.
the line in code its pointing out is
\"\"if (!in_array($the_file_type,$allowed_types1)){
echo\"the file u have tried to upload is not allowed.\";
But when i run this file saperately it works fine. plz respond me to prasadtn@infovation.com
function validate_upload($file_up) {
$allowed_types1= array(\"text/plain\");
global $my_max_file_size, $image_max_width, $image_max_height,$allowed_types1,$the_file_type,$registered_types;
$start_error = \"\\n<b>Error:</b>\\n<ul>\";
if ($file_up == \"none\") { # do we even have a file?
$error .= \"\\n<li>You did not upload anything!</li>\";
} else { # check if we are allowed to upload this file_type
if (!in_array($the_file_type,$allowed_types1)) {
$error .= \"\\n<li>The file that you uploaded was of a type that is not allowed, you are only
allowed to upload files of the type:txt files only\\n<ul>\";
//while ($type = current($allowed_types1)) {
//$error .= \"\\n<li>\" . $registered_types[$type] . \" (\" . $type . \")</li>\";
//next($allowed_types1);
// }
// $error .= \"\\n</ul>\";
}
if (ereg(\"image\",$the_file_type) && (in_array($the_file_type,$allowed_types1))) {
$size = GetImageSize($file_up);
list($foo,$width,$bar,$height) = explode(\"\\\"\",$size[3]);
if ($width > $image_max_width) {
$error .= \"\\n<li>Your image should be no wider than \" . $image_max_width . \" Pixels</li>\";
}
if ($height > $image_max_height) {
$error .= \"\\n<li>Your image should be no higher than \" . $image_max_height . \" Pixels</li>\";
}
}
if ($error) {
$error = $start_error . $error . \"\\n</ul>\";
return $error;
} else {
return false;
}
}
} # END validate_upload
--
/*function list_files() {
global $the_path;
$handle = dir($the_path);
print \"\\n<b>Uploaded files:</b><br>\";
while ($file = $handle->read()) {
if (($file != \".\") && ($file != \"..\")) {
print \"\\n\" . $file . \"<br>\";
}
}
print \"<hr>\";
}*/
--
function upload($file_up) {
global $the_path,$the_file_name;
$error = validate_upload($file_up);
if ($error) {
form($error);
} else { # cool, we can continue
if (!@copy($file_up, $the_path . \"/\" . $the_file_name)) {
form(\"\\n<b>Something barfed, check the path to and the permissions for the upload directory</b>\");
} else {
//list_files();
//form();
echo \"file uploaded\";