Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.