Hello again, tried to remove the last part and the script worked, it looks
like strip_tags strips more than tags...
Thanks a lot
Lizet

-----Original Message-----
From: John Holmes [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 23, 2004 3:02 PM
To: Lizet Peņa de Sola; [EMAIL PROTECTED]
Subject: Re: [PHP] Upload script not working


From: "Lizet Peņa de Sola" <[EMAIL PROTECTED]>
> 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);

I don't notice anything wrong with the script after glancing through it. If 
you take out the end portion where you strip the tags from the file, so you 
still end
up with a smaller file as a result? Maybe strip_tags() is removing more 
content than you think it is? Either way, you're going to end up with a 
smaller file.

---John Holmes... 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to