php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21908 File upload problems beginning in 4.3.0
Submitted: 2003-01-27 12:38 UTC Modified: 2003-02-04 15:19 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:1 (33.3%)
From: fn at panix dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.0 OS: NetBSD-1.5.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fn at panix dot com
New email:
PHP Version: OS:

 

 [2003-01-27 12:38 UTC] fn at panix dot com
I am running the following code in php-4.3.0:
<?
    $portrait = $_FILES["portrait"];

print "<hr>_FILES[portrait]: <pre>\n";
print_r($portrait);
print "</pre>";

    $portrait = $_GLOBALS["portrait"];

print "<hr>_FILES[portrait]: <pre>\n";
print_r($portrait);
print $_FILES["portrait"]["error"];
print "</pre>";

?>
<form method="post"
      action="t.cgi"
      ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000">
<input type=file name=portrait>
<input type="submit">
</form>

The file does not appear to be uploaded.  However, with php-4.2.3,
everything works fine.  I have confirmed that both file_uploads and
register_globals are on.  This problem occurs in both the apache module
and the standalone version.
is_uploaded_file() also reports failure with php-4.3.0.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-27 17:09 UTC] sniper@php.net
What apache version? What is the output of your script?

 [2003-01-28 12:47 UTC] fn at panix dot com
There is no error message from that script.  It fails silently.

We are using Apache-1.3.27.

Thanks for your help.
 [2003-01-29 00:02 UTC] sniper@php.net
And is PHP compiled as module in Apache or are you
running it as CGI?

 [2003-01-29 09:34 UTC] fn at panix dot com
We are running both the apache module and the cgi.  The problem is present in both.  However, it was not present in 4.2.3 (both the apache module and the standalone version).
 [2003-01-31 09:21 UTC] arkadi at it dot lv
I also expirienced this problem. In my case I had "file_uploads = Off" in php.ini and then "php_flag file_uploads on" for every virtual host that require upload. That works perfectly in 4.2.3. According to phpinfo() setting private flag have no effect for this option in 4.3.0. I was forced to enable file uploads on system level in php.ini to solve the problem.
 [2003-02-03 07:29 UTC] sniper@php.net
Please try this script:

<form method="post" action="upload.php" enctype="multipart/form-data">
<input type="file" name="portrait">
<input type="submit">
</form>
<?php

error_reporting(E_ALL);
var_dump($_FILES); 

?>

If $_FILES array is empty after submit and no errors are given, try this script:

<?php phpinfo(); ?> 

And check the file upload related settings from the output:

post_max_size
file_uploads
upload_tmp_dir
upload_max_filesize

Also check your Apache error_log for any errors.

 [2003-02-03 13:32 UTC] evatckovacs at netscape dot net
Hello.
I am also finding this error. I am actually running on Linux but everything else is the same version. this is kind of stolen out of the wrox book. the variable $afile is empty but $crud gets passed over just fine. am i referring to it incorrectly? this is making me nuts and i have an enduser crawling on me to get his scripts fixed. please help.

thank you

[kovacs@darth eva]$ more cispt1test.php
<?
function upload_form() {
        global $phpself;
        $phpself = $_SERVER["PHP_SELF"];
        print "<form name='formtest' method='post' enctype='multipart/form-data'
 action='$phpself'>";
        print "<input type='hidden' name='action' value='upload'>";
        print "<input type='file' name='afile'>";
        print "<input type='text' name='crud'>";
        print "<input type='submit' name='submit' value='upload'>";
        print "<input type='reset' name='reset' value='reset'>";
        print "</form>";

}

function upload_file() {
        global $afile;
        error_reporting(E_ALL);
        $afile = $_POST["afile"];
        $crud = $_POST["crud"];
        print "some stuff";
        print "$afile $crud";
        if (!@copy($afile,"/tmp/crud")) die ("Can't upload");
        var_dump($_FILES);

}
?>

<html>
<head><title>test</title>
<meta http-equiv = "Content-type" content="text/html; charset=iso-8859-1">
</head>
<body>

<?
        $action = $_POST["action"];
        print "action = $action";
        if ($action == 'upload') upload_file();
        else upload_form();
?>

</body></html>
 [2003-02-03 13:36 UTC] fn at panix dot com
The problem for me was that upload_tmp_dir did not need to be set in 4.2.3.  By default, it used /tmp.  Now if it isn't set, nothing happens.  However, now that it is set in the php.ini everything is working again.
 [2003-02-04 10:41 UTC] evatckovacs at netscape dot net
hi -
i set the file upload dir but the problem is still happening and seems to be a little different. my filename variable does not get passed over in the post when in the same php program. i have not tried an html that calls a standalone php yet, but the $afile variable below holds nothing when you output contents while $crud does. maybe $_POST is not valid for filenames? or? should i just write email directly to someone? i promise i've looked at all the docs and grovelled for help locally.  
thank you. 
evatc
 [2003-02-04 11:48 UTC] michael dot mauch at gmx dot de
For file uploads it's $_FILES, not $_POST.

Please read
<http://www.php.net/manual/en/features.file-upload.php>.
 [2003-02-04 15:14 UTC] evatckovacs at netscape dot net
thank you. i am dumb. i saw the FILES stuff and blew it off as being irrelevant, for whatever reason. thank you again.
 [2003-02-04 15:19 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

based on user comments the code works fine, the errors were due to configuration issues or misunderstanding of the docs.
 [2003-05-10 12:36 UTC] androbtech at monosalvaje dot com
I got the following code and Im running PHP 4.3.0 For MAC OS X, the last Version is not avilable...

<?php
	/* funciones para fotos */
	

			if($_GET["x"] == "despues") {
?>	
	<form method="post" enctype="multipart/form-data" action="ja.php?x=ahora">
				<table width="440" height="412" border="0" cellpadding="0" cellspacing="8">
                	<tr>
						<td height="187" valign="top"> 
							<span class=submenu>Para poder subir imagenes a la base de datos le pedimos lo siguiente:</span><br><br>
                  			<table width="341" border="1" align="center" cellpadding="0" cellspacing="8" bordercolor="#FFFFFF" bgcolor="#003333" class="texto">
                    			<tr> 
                            		<td colspan="2">Datos:</td>
                    			</tr>
                    			<tr> 
                      				<td width="45" align="right">Nombre:</td>
                      				<td width="125"><input name="nombre" type="text" class="textbox"></td>
                    			</tr>
                    			<tr> 
                      				<td align="right">Juego:</td>
                     				<td><input name="juego" type="text" class="textbox"></td>
                    			</tr>
                   				<tr> 
                      				<td align="right">Consola:</td>
                     				<td>
					  					<select name="consola" class="textbox">
                                			<option value="GC">Nintendo GameCube</option>
					  						<option value="N64">Nintendo 64</option>
					  						<option value="PS2">Playstation 2</option>
					  						<option value="PS">Playstation</option>
					  						<option value="XBOX">XBOX</option>
					  					</select>
					  				</td>
                    			</tr>
                    			<tr> 
                      				<td align="right">Imagen:</td>
                     				 <td><input type="file" name="imagen" class="filebox"></td>
                    			</tr>
                  			</table>
							  
							<center><input type=submit name=submit value="Subir imagen" class="subbox"></center>
                		</td>
              		</tr>
            </table>
		</form>
	
<?php 
			} elseif ($_GET["x"] == "ahora") {
					require("php-bin/seguridad/panel/configuracion.php");	
					
					$conn = mysql_connect($db_servidor,$db_usuario,$db_clave);
						
						if(is_uploaded_file($_FILES["imagen"])) {
							echo("imagen subida");		
							$imagen = fopen($_FILES["imagen"], "r");
							$datos = fread($imagen, filesize($_FILES["imagen"])); 
							$datos = addslashes($datos);
						}
					
					$query = "INSERT INTO thumbs VALUES ('','$_POST[juego]','$_POST[consola]','$_POST[nombre]','".$_FILES['imagen']['type']."','','$datos')";
					if(mysql_db_query($db_nombre,$query,$conn)) {
						$err = "0";
					} else {
						$err = "3";
					}
					
					$conn = mysql_close($conn);
?>
todo subido, todo bien.
<?php
			} else {
				echo("ninguna opcion");
			}

?>
 [2003-05-10 12:40 UTC] androbtech at monosalvaje dot com
Me again , I forgot to add something,

the function is_uploaded_file() does not work, I don;t know why and in older versions this script used to work 100% perfect and NOW -100% wrong
 [2003-07-07 08:22 UTC] php at memoclic dot com
Same pb for me.

Upgraded from 4.1.2 (on a Slackware) to 4.3 and uploads won't work with file_uploads on Off in php.ini.

I activated uploads via an .htaccess. Worked fine in 4.1.2 (php code was **not** modified).

I also tried with ini_set() but didn t work either.

Hope this will help resolving.
 [2003-07-25 09:17 UTC] nakielan at poczta dot fm
J dont have $_FILE ("array(0) { }") in Openwall Linux but J have $FILE in Mandrake 9.0 .

On both systems J have the some apache,php,test files, configuracion files

please help ... ?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 07:01:34 2024 UTC