I'm running through a book on Dreamweaver CS5 and PHP, and it uses the Zend
framework for most of the commands it's teaching. I've run into a brick
wall trying to figure out why I can't get it to recognize the mimetype of
images. Code follows:
upload_test.php (This submits the file)
<?php
require_once('scripts/process_upload.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
if (isset($messages)) {
echo '<ul>';
foreach ($messages as $item) {
echo "<li>$item</li>";
}
echo '</ul>';
}
?>
<form action"" method="post" enctype = "multipart/form-data" name="form1"
id="form1">
<p>
<input name="MAX_FILE_SIZE" type="hidden" id="MAX_FILE_SIZE"
value="51200" />
<label for="upload_file">File to upload</label>
<input type="file" name="upload_file" id="upload_file" />
</p>
<p>
<input type="submit" name="upload" id="upload" value="Upload File" />
</p>
</form>
</body>
</html>
process_upload.php (this handles all the validation, etc.)
<?php
if (isset($_POST['upload'])) {
require_once('library.php');
try {
$destination = 'C:/upload_test';
$uploader = new Zend_File_Transfer_Adapter_Http();
$uploader->setDestination($destination);
$uploader->addValidator('Size', FALSE, '50kB');
$uploader->addValidator('MimeType', FALSE, 'image');
$success = $uploader->receive();
if (!$success) {
$messages = $uploader->getMessages();
} else{
$filename = $uploader->getFileName(NULL, FALSE);
$messages[] = "$filename uploaded successfully";
}
} catch (Exception $e) {
echo $e->getMessage();
}
}
Seems straighforward, and it SHOULD capture the mime type. However, I
consistently get the following on running the firs file:
The mimetype of file 'birds_of_a_feather.jpg' could not be detected
Doesn't matter what file I try to upload (image file, that is) as long as
it's withing the size limitations, it should come through. It doesn't. I
get the above error message every time. Can anyone help?
Gene
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/MimeType-failure-tp3634381p3634381.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]