Jump to content

[SOLVED] Weird upload problem


phpknight

Recommended Posts

I am testing out a PEAR example.  For some reason, it works just fine if I try to upload a gif, but if I use a jpg or png, the PEAR error says the file is missing.  All the files are only 1KB.  Anybody have this problem before?  If so, how did you fix it?

 

The form code is this:

 

<form enctype="multipart/form-data" action="uploadtest.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="200000"/>
File to upload: <input name="myFile" type="file"/>
<input type="submit" name="submit" value="Upload"/>
</form>

 

PEAR code:

require_once('HTTP/Upload.php');
if (isset($_POST['submit'])&& $_POST['submit']=='Upload')
{


$upload=new HTTP_Upload('en');



$file=$upload->getFiles('myFile');



if (PEAR::isError($file))
{	
	die ($file->getMessage());
}



if ($file->isValid())
{

	$uploadDirectory="/uploaddirhere/";
	$file->setName('safe');
	$uploadName=$file->moveTo($uploadDirectory);
	if (PEAR::isError($uploadName))
	{

		die($uploadName->getMessage());
	}

echo 'The file <strong>'. $file->getProp('real').'</strong> has been upload to the <em>'.$uploadDirectory.'</em> directory and rename to <strong>'.$uploadName.'</strong>.';

}
else
{


	print $file->getMessage();
		var_dump($_POST);
}
}

Link to comment
https://forums.phpfreaks.com/topic/65695-solved-weird-upload-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.