|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12283 File uploads: some filetypes work, some don't
Submitted: 2001-07-20 10:11 UTC Modified: 2001-08-19 15:20 UTC
From: peter at vruggink dot net Assigned:
Status: Not a bug Package: HTTP related
PHP Version: 4.0.6 OS: Linux 2.2.16-22 (RedHat 7.0)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: peter at vruggink dot net
New email:
PHP Version: OS:


 [2001-07-20 10:11 UTC] peter at vruggink dot net
I have a problem with file uploads on my PHP configuration. Some filetypes get uploaded (e.g. BMP, GIF, TXT), while others don't get uploaded (for example: MSWORD, PDF, EXCEL).

I use the following testfiles:

  <title>Administration - upload new files</title>
<h1>Upload new news files</h1>
<form enctype="multipart/form-data" action="upload.php" method="post">
  <input type="hidden" name="MAX_FILE_SIZE" value="1000">
  Upload this file: <input name="userfile" type="file">
  <input type="submit" value="Send File">

<h1>Uploading file...</h1>
	echo "file: " .   $userfile . "<BR>\n";
	echo "name: " . $userfile_name . "<BR>\n";
	echo "type: " . $userfile_type . "<BR>\n";
	echo "size: ". $userfile_size ."<P>\n";

if(is_uploaded_file ($userfile))

  $upfile = "/home/projectweb/files/". $userfile_name;

  if ( !copy($userfile, $upfile)) 
    echo "Problem: Could not move file into directory"; 

  echo "File uploaded successfully<br><br>"; 
  $fp = fopen($upfile, "r");
  $contents = fread ($fp, filesize ($upfile));
  fclose ($fp);
  $contents = strip_tags($contents);
  $fp = fopen($upfile, "w");
  fwrite($fp, $contents);

  echo "Preview of uploaded file contents:<br><hr>";
  echo $contents;
  echo "<br><hr>";
	echo "There is no file uploaded!";


Result with a BMP file:

file: /tmp/files/phpNGn0H0
naam: at.BMP
type: image/bmp
size: 230
File uploaded successfully

Preview of uploaded file contents:

Result with a Microsoft Word file:

file: none
naam: Doc1.doc
type: application/msword
size: 0

There is no file uploaded! 

I'm puzzeled. Any ideas?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-19 04:00 UTC]
I would think a Word file is a lot bigger always than 1000 bytes.. So try changing that first.


 [2001-08-19 06:23 UTC] peter at vruggink dot net
I did increase the size, but with the same results. I also tried other upload scripts from the internet, with mixed results (unpredictable) on different systems. And in my opinion the script I wrote is OK.
Could there also be a browser problem with Internet Explorer 5 and 5.5?
 [2001-08-19 06:48 UTC]
Next question is: Does this happen with other browsers, like
with Netscape?

 [2001-08-19 08:07 UTC] peter at vruggink dot net
I tried it again with the same script on my home configuration (linux RH 7.0 + php 4.06) and it worked after increasing the max file size. I made a mistake in the file size, i.e. overlooked a 0 I think :-(
I'm sorry for the commotion. You can close this bug report.

 [2001-08-19 15:20 UTC]
user error

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 12:01:28 2024 UTC