Hi all:
I have the following script to upload files to the server, it works
partially as only a few bytes of the file are uploaded, is the script wrong
or am I missing some setting at the server?
Tia,
Lizet
userfile=$_FILES['userfile']['tmp_name'];
// $userfile_name is the original file name without spaces
$userfile_name=str_replace(" ","_",$_FILES['userfile']['name']);
// $userfile_size the size in bytes
$userfile_size=$_FILES['userfile']['size'];
//$userfile_type is mime type e.g. image/gif
$userfile_type=$_FILES['userfile']['type'];
// $userfile_error is any error encountered
$userfile_error=$_FILES['userfile']['error'];
if($userfile_error > 0){
$str="Problem: ";
switch ($userfile_error){
case 1: $str=$str."error 1"; break;
case 2: $str=$str."error2"; break;
case 3: $str=$str."erro3"; break;
case 4: $str=$str."error4"; break;
}
exit;
}
$upfile= 'files/'.$userfile_name;
$temp1=is_uploaded_file($userfile);
if($temp1){
$temp2=move_uploaded_file($userfile,$upfile);
if(!$temp2){
$str="Problem: The file could not be moved.";
//exit;
}
}
else{
$str="Problem: file corrupted: ".$userfile_name;
}
//reformat the file contents:
$fp= fopen($upfile,'r');
$contents = fread($fp, filesize($upfile));
fclose($fp);
$contents= strip_tags($contents);
$fp= fopen($upfile,'w');
fwrite($fp,$contents);
fclose($fp);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php