Error uploading image : A valid image file is required

Author Message

CALMUS Julien

Friday 22 April 2011 7:03:10 am

I have a problem on one of my plateform.

On the admin interface when I create or edit a content with an image. When I validate it I get this message :

"Required data is either missing or is invalid:
Image: A valid image file is required."

To another plateform with the same ez publish configuration. I have no problem. I have no idee.

In ez Publish files I find where the error message come from : ezimagetype.php :

function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
{
$classAttribute = $contentObjectAttribute->contentClassAttribute();
$httpFileName = $base . "_data_imagename_" . $contentObjectAttribute->attribute( "id" );
$maxSize = 1024 * 1024 * $classAttribute->attribute( self::FILESIZE_FIELD );
$mustUpload = false;
if( $contentObjectAttribute->validateIsRequired() )
{
$tmpImgObj = $contentObjectAttribute->attribute( 'content' );
$original = $tmpImgObj->attribute( 'original' );
if ( !$original['is_valid'] )
{
$mustUpload = true;
}
}
$canFetchResult = eZHTTPFile::canFetch( $httpFileName, $maxSize );
if ( isset( $_FILES[$httpFileName] ) and $_FILES[$httpFileName]["tmp_name"] != "" )
{
$imagefile = $_FILES[$httpFileName]['tmp_name'];
if ( !$_FILES[$httpFileName]["size"] )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
'The image file must have non-zero size.' ) );
return eZInputValidator::STATE_INVALID;
}
if ( function_exists( 'getimagesize' ) )
{
$info = getimagesize( $imagefile );
if ( !$info )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
'A valid image file is required.' ) );
return eZInputValidator::STATE_INVALID;
}
}
else
{
$mimeType = eZMimeType::findByURL( $_FILES[$httpFileName]['name'] );
$nameMimeType = $mimeType['name'];
$nameMimeTypes = explode("/", $nameMimeType);
if ( $nameMimeTypes[0] != 'image' )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
'A valid image file is required.' ) );
return eZInputValidator::STATE_INVALID;
}
}
}
if ( $mustUpload && $canFetchResult == eZHTTPFile::UPLOADEDFILE_DOES_NOT_EXIST )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
'A valid image file is required.' ) );
return eZInputValidator::STATE_INVALID;
}
if ( $canFetchResult == eZHTTPFile::UPLOADEDFILE_EXCEEDS_PHP_LIMIT )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
'The size of the uploaded image exceeds limit set by upload_max_filesize directive in php.ini. Please contact the site administrator.' ) );
return eZInputValidator::STATE_INVALID;
}
if ( $canFetchResult == eZHTTPFile::UPLOADEDFILE_EXCEEDS_MAX_SIZE )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
'The size of the uploaded file exceeds the limit set for this site: %1 bytes.' ), $maxSize );
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
}

If anybody have an idee you are welcome.

Finally sorry for my English I'm a Frenchy user ;).

Betsy Gamrat

Monday 25 April 2011 5:44:57 am

Possible causes:

Permission issue - eZ can't move the image into the var directory - check the directory and file permissions with ls -la

Configuration issue - the MIME type for the uploaded image isn't on the server as an image

http://httpd.apache.org/docs/current/mod/mod_mime.html

The client PC may also have the image type associated with a different MIME type

Image type - is the image an icon?

More information:

Which eZ version?

Server type/version, MIME settings (/etc/httpd/conf/httpd.conf is a good place to start)

PHP verison

Directory permissions for var directory

Check /etc/httpd/logs/error_log and var/log/error.log

CALMUS Julien

Monday 02 May 2011 1:17:43 am

No the image isn't an icon. It's a PNG file.

eZ version is 4.3.0.

var directory permissions is the first think I check, no problem on it, all permissions available.

PHP 5, Apache 2, I haven't the exact versions because I only have a FTP access on this server.

I didn't find /etc/httpd/ directory on my server (work fine) or on the server which have the image problem. So I can't check MIME setting. Have you an idee how to find this settings?

Thanks a lot

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:09:53
Script start
Timing: Jan 18 2025 02:09:53
Module start 'layout'
Timing: Jan 18 2025 02:09:53
Module start 'content'
Timing: Jan 18 2025 02:09:54
Module end 'content'
Timing: Jan 18 2025 02:09:54
Script end

Main resources:

Total runtime0.6716 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.0625152.6406
Module start 'layout' 0.00500.0027 740.703139.4844
Module start 'content' 0.00770.6625 780.1875529.1172
Module end 'content' 0.67020.0013 1,309.304712.1250
Script end 0.6715  1,321.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.4408160.0002
Check MTime0.00120.1824160.0001
Mysql Total
Database connection0.00060.090410.0006
Mysqli_queries0.610090.8298570.0107
Looping result0.00040.0617550.0000
Template Total0.648296.520.3241
Template load0.00190.281720.0009
Template processing0.646396.239320.3232
Template load and register function0.00030.041810.0003
states
state_id_array0.00080.113010.0008
state_identifier_array0.00070.110320.0004
Override
Cache load0.00170.25551070.0000
Sytem overhead
Fetch class attribute can translate value0.00040.060020.0002
Fetch class attribute name0.00110.164440.0003
XML
Image XML parsing0.00070.106020.0004
class_abstraction
Instantiating content class attribute0.00000.001540.0000
General
dbfile0.00090.1279160.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs