Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-03-2008, 02:35 PM
Junior Member
 
Join Date: Oct 2008
Posts: 13
Default Zend_file_transfer validators don't work :(

Hello everybody,

I have a simple upload form and it had worked perfectly until recently. It seems that file transfer validators don't work. I want them to validate simple images.

FilesSize validator always gives "All files in sum should have a maximum size of '0B' but '1550' were detected"

MymeType validator says "The file 'image.gif' has a false mimetype of 'image/gif'"

ImageSize validator doesn't throw an error, but it doesn't validate either. If I exclude validators, upload succeeds. I regularly update zend using subversion. Can somebody please help me, I don't know what else to try to make iz work. Thanks

Here is the code:
PHP Code:
$upload = new Zend_File_Transfer_Adapter_Http();

$upload->addValidator('FilesSize', array('1B''100kB'));
$upload->addValidator('MimeType''image');
$upload->addValidator('ImageSize'11001188);
            
$upload->setDestination('...');
if (!
$upload->receive()) ... 

Last edited by kiboke : 10-03-2008 at 02:38 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-03-2008, 04:02 PM
Member
 
Join Date: Aug 2008
Posts: 67
Default

And you think that anyone can say something about your problem, without to know what your file was ?
__________________
Greetings
Thomas Weidner
I18N Team Leader, Zend Framework
http://www.thomasweidner.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-03-2008, 06:50 PM
Junior Member
 
Join Date: Oct 2008
Posts: 13
Default

Quote:
Originally Posted by thomas View Post
And you think that anyone can say something about your problem, without to know what your file was ?
i gave the relevant code that is all that is connected to file uploading. and all worked well for few months, a week ago stoped working on all of my projects.

what other information should i provide? thanks for helping me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-03-2008, 08:20 PM
Member
 
Join Date: Aug 2008
Posts: 67
Default

As I said... declare your file... without the knowledge what you've uploaded how can we say whats going wrong ?

How your code works changes with every file you upload.
__________________
Greetings
Thomas Weidner
I18N Team Leader, Zend Framework
http://www.thomasweidner.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 10-04-2008, 03:39 PM
Junior Member
 
Join Date: Oct 2008
Posts: 13
Default

Quote:
Originally Posted by thomas View Post
As I said... declare your file... without the knowledge what you've uploaded how can we say whats going wrong ?

How your code works changes with every file you upload.
Here it is, this simple test code works perfectly on 1.6.1 release (15.9.2008.) but if i download the latest version via svn...

PHP Code:
<?php

set_include_path
('/var/www/common/zend/library' PATH_SEPARATOR get_include_path());

include 
'Zend/File/Transfer/Adapter/Http.php';

$upload = new Zend_File_Transfer_Adapter_Http();

$upload->addValidator('FilesSize', array('1B''100kB'))
    ->
addValidator('ImageSize'12001200)
    ->
addValidator('MimeType''image')
    ->
setDestination('/var/www/images');

if (!
$upload->receive())
    echo 
implode("<br />"$upload->getMessages());

?>

<form action="" enctype="multipart/form-data" method="post">
    <input type="file" name="file" />
    <input type="submit">
</form>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 10-04-2008, 10:27 PM
Member
 
Join Date: Aug 2008
Posts: 67
Default

Superb... and now give us the $_FILES array you uploaded and the returned error messages which holds the information of the file you uploaded and is what I wanted.

Then we will see where your problem is.
__________________
Greetings
Thomas Weidner
I18N Team Leader, Zend Framework
http://www.thomasweidner.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 10-05-2008, 05:31 AM
Junior Member
 
Join Date: Oct 2008
Posts: 13
Default

$_FILES:

PHP Code:
Array
(
    [
file] => Array
        (
            [
name] => 16-em-pencil.gif
            
[type] => image/gif
            
[tmp_name] => /tmp/phpqz9r5j
            
[error] => 0
            
[size] => 133
        
)


Warnings and error that previously haven't existed:

PHP Code:
WarningInvalid argument supplied for foreach() in /var/www/common/zend/trunk/library/Zend/Validate/File/MimeType.php on line 127
All files in sum should have a maximum size of 
'0B' but '133' were detected 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 10-05-2008, 08:34 AM
Member
 
Join Date: Aug 2008
Posts: 67
Default

When working with the latest release you should also read the manual of the latest release.

In conjunction to Zend_Form a breakChainOnFailure parameter was added.
Looking in the API doc of addValidator you would have seen this.

Simply add a "false" or "true" in front of the parameters like you are doing when using forms.
__________________
Greetings
Thomas Weidner
I18N Team Leader, Zend Framework
http://www.thomasweidner.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 10-05-2008, 02:59 PM
Junior Member
 
Join Date: Oct 2008
Posts: 13
Default

Quote:
Originally Posted by thomas View Post
When working with the latest release you should also read the manual of the latest release.

In conjunction to Zend_Form a breakChainOnFailure parameter was added.
Looking in the API doc of addValidator you would have seen this.

Simply add a "false" or "true" in front of the parameters like you are doing when using forms.
It works. Thanks for your patience and help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 10-31-2008, 02:29 PM
Junior Member
 
Join Date: Oct 2008
Posts: 13
Unhappy

I don't get it. Another update and it doesn't work again.

$upload->addValidator('MimeType', true, 'image'); allows me to upload any kind of file.

PHP code is the save as before (please see older replies to this thread). $_FILES sais:

PHP Code:
Array
(
    [
file] => Array
        (
            [
name] => placement posao.doc
            
[type] => application/msword
            
[tmp_name] => /tmp/php9yUzgm
            
[error] => 0
            
[size] => 53248
        
)


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 12:32 AM.