Problem with image

A place for users and developers of the Xataface to discuss and receive support.

Postby siainmi » Thu Sep 13, 2007 12:54 am

Hi, I have dataface v. 0.7.1 and when i try to view a image from db i have this error:
trovato:/tmp/GestFarm-diagnostica-image-0?iddignostica=23&-1189668558
Warning: fopen(/tmp/GestFarm-diagnostica-image-0?iddignostica=23&-1189668558) [function.fopen]: failed to open stream: Invalid argument in E:\Programmi\OCS Inventory NG\xampp\htdocs\dataface\Dataface\Application\blob.php on line 174

Warning: Cannot modify header information - headers already sent by (output started at E:\Programmi\OCS Inventory NG\xampp\htdocs\dataface\Dataface\Application\blob.php:173) in E:\Programmi\OCS Inventory NG\xampp\htdocs\dataface\Dataface\Application\blob.php on line 229

Warning: Cannot modify header information - headers already sent by (output started at E:\Programmi\OCS Inventory NG\xampp\htdocs\dataface\Dataface\Application\blob.php:173) in E:\Programmi\OCS Inventory NG\xampp\htdocs\dataface\Dataface\Application\blob.php on line 230

database name is GestFarm, table name is Diagnostica and field is:
iddiagnostica : Primary key autoincremental
data : Date field
Image : Blob
Imaga_mine : varchar(10) default="jpeg"

i try to set:
class tables_Diagnostica {
function image__htmlValue(&$record)
{
return 'display('image').'">';
}
}
siainmi
 
Posts: 30
Joined: Wed Dec 31, 1969 5:00 pm

Postby siainmi » Thu Sep 13, 2007 1:02 am

sorry I send before finish!

class tables_Diagnostica {
function image__htmlValue(&$record)
{
return 'display('image').'">';
}
}

but I can see nothing!
siainmi
 
Posts: 30
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Thu Sep 13, 2007 9:12 am

There are 2 ways to fix this issue:

1. add a valid path to be used as a cache directory to the first line of your conf.ini file:

e.g.

cache_dir = "C:\xamp\path\to\tmp\folder"

and make sure that this folder is writable on the webserver.

2.Ê You can add some more "smartness" to the source code.Ê In Dataface/Application.php on line 382 you'll see something like:

ÊÊÊ ÊÊÊ if ( !isset( $this->_conf['cache_dir'] ) ){
ÊÊÊ ÊÊÊ ÊÊÊ $this->_conf['cache_dir'] = '/tmp';
ÊÊÊ ÊÊÊ }

Change it to:

if ( !isset( $this->_conf['cache_dir'] ) ){
ÊÊÊ ÊÊ ÊÊÊ Êif ( ini_get('upload_tmp_dir') ) $this->_conf['cache_dir'] = ini_get('upload_tmp_dir');
ÊÊÊ ÊÊ ÊÊÊ Êelse $this->_conf['cache_dir'] = '/tmp';
ÊÊÊ ÊÊ Ê}


Ê ÊÊ

--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby siainmi » Mon Sep 24, 2007 5:36 am

Hi!

If I write this in Dataface/Application.php :

if ( !isset( $this->_conf['cache_dir'] ) ){
if ( ini_get('upload_tmp_dir') ) $this->_conf['cache_dir'] = ini_get('upload_tmp_dir');
else $this->_conf['cache_dir'] = '/tmp';
}

I get this error when open link to image (Action getBlog) =

Warning: fopen(E:\Programmi\OCS Inventory NG\xampp\tmp/GestFarm-diagnostica-image-0?iddignostica=23&-1190636882) [function.fopen]: failed to open stream: Invalid argument in E:\Programmi\OCS Inventory NG\xampp\htdocs\dataface\Dataface\Application\blob.php on line 174

Warning: Cannot modify header information - headers already sent by (output started at E:\Programmi\OCS Inventory NG\xampp\htdocs\dataface\Dataface\Application\blob.php:173) in E:\Programmi\OCS Inventory NG\xampp\htdocs\dataface\Dataface\Application\blob.php on line 229

Warning: Cannot modify header information - headers already sent by (output started at E:\Programmi\OCS Inventory NG\xampp\htdocs\dataface\Dataface\Application\blob.php:173) in E:\Programmi\OCS Inventory NG\xampp\htdocs\dataface\Dataface\Application\blob.php on line 230

Then if I change conf.ini adding:

cache_dir = "E:\tmp"

with tmp folder writeable for everyone I get this:

Warning: fopen(E:\tmp/GestFarm-diagnostica-image-0?iddignostica=24&-1190637166) [function.fopen]: failed to open stream: Invalid argument in E:\Programmi\OCS Inventory NG\xampp\htdocs\dataface\Dataface\Application\blob.php on line 174


Thanks For Help!
siainmi
 
Posts: 30
Joined: Wed Dec 31, 1969 5:00 pm

Postby siainmi » Mon Sep 24, 2007 5:58 am

if I put fopen("e:\\tmp\Scrive.txt","w"); before blob.php line 174 that file is create correctly
siainmi
 
Posts: 30
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon Sep 24, 2007 5:35 pm

Hmm.. This may be a limitation in Windows file names. Dataface tries to cache the blob files temporarily..

Perhaps try simplifying cache file names. In the file Dataface/Application/blob.php, you should find a section like:
Code: Select all
$cachePath = $this->_conf['cache_dir'].'/'.$this->_conf['_database']['name'].'-'.$tablename.'-'.$fieldname.'-'.$index.'?';
      foreach ($keys as $key){
         $cachePath .= urlencode($key).'='.urlencode($_REQUEST[$key]).'&';
      }


in the _handleGetBlob() function

Try adding the following right after it:
$cachePath = $this->_conf['cache_dir'].'/'.md5($cachePath);

That should produce a more friendly file name.
This isn't a perfect solution as there is a small probability of collisions in file names with this strategy... but it will at least tell us whether that is the problem.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby siainmi » Tue Sep 25, 2007 8:00 am

HI Very very good work! Now working all, I have crete this method:
function image__htmlValue(&$record)
{
if ($record->val('image_minetype')=="application/x-shockwave-flash")
{
return '
';
}
elseif ($record->val('image_minetype')=="application/pdf")
{
return '';

//return 'display('image').'"> link ';
}
else
return 'display('image').'">';
}


and I can see Pdf, flash and image. in fields.ini I have put:
[image_minetype]
widget:type = select
vocabulary = mime_type

[image]
type = container
widget:type = file
widget:label = "Upload"
allowed_extensions = pdf,swf,jpeg

and in valueslist.ini

[mime_type]
application/x-shockwave-flash = flash
application/pdf = pdf
image/jpeg = image JPEG

now I have last problem: I wont to upload only file with extensions = pdf,swf,jpeg but don't work!
where I have make mistake?

Thank for all!!
siainmi
 
Posts: 30
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Tue Sep 25, 2007 8:08 am

OK.. there are a couple of things here:

1. It should be "Type = container" and not "type = container" (case sensitive)
2. Are you using a container field or a blob field. In the container field strategy (recommended), you use a varchar field to store the file name. In a blob field strategy, you actually store the file in the db. I'm not sure if the allowed_extensions directive works for blob fields (i'll have to look). It was more important for container fields because the files are actually being stored on the file system and there are potential security issues... none the less it would be good to have this feature for blobs too.

3. You cite a couple of places in your sample code when you are using 'image_minetype'. Do you mean 'image_mimetype'?

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby siainmi » Thu Sep 27, 2007 7:36 am

Hi I have change minetype to mimetype, and now working fine, image_filename too....Sorry for error!!!!
with this fields.ini allowed_extensions don't work, but is not a great problems!
Thx for All!!

[image]
Type = blob
widget:type = file
allowed_extensions = pdf,swf,jpeg
siainmi
 
Posts: 30
Joined: Wed Dec 31, 1969 5:00 pm

Postby Paul » Thu Feb 28, 2008 9:10 pm

Hi Steve,

Sorry to renew an old thread but I just wanted to advise that I had the same problems using a windows server with the cachepath name.

Adding the line

Code: Select all
$cachePath = $this->_conf['cache_dir'].'/'.md5($cachePath);


as advised above fix the problem. Perhaps this can be included in future releases.

Regards,

Paul
Paul
 
Posts: 20
Joined: Wed Jan 30, 2008 12:04 am

Postby fantomasdm » Thu Mar 26, 2009 2:29 am

HI!!
I have same problemes with creation file on windows server,
the error is:
Warning: fopen(d:/tmp/riparazioni-riparazione-Allegato-0?ID=26&-1238059310) [function.fopen]: failed to open stream: No error in D:\xampp\htdocs\xataface-1.1.5r2\Dataface\Application\blob.php on line 173

the problems is file name with "?" can't create on windows!

using a simple str_replace "?", ":" ????
fantomasdm
 
Posts: 114
Joined: Thu Mar 13, 2008 2:35 pm

Postby fantomasdm » Thu Mar 26, 2009 8:45 am

with add this line it's work
$found=str_replace("?","-",$found);
fantomasdm
 
Posts: 114
Joined: Thu Mar 13, 2008 2:35 pm

Re: Problem with image

Postby inmisia » Wed Mar 10, 2010 2:55 am

Hi, I have same problem, and with replace $found=str_replace("?","-",$found); it works!
Is possible to make the update on all release of xatafce for prevent problems on windows server??
inmisia
 
Posts: 16
Joined: Tue Nov 06, 2007 2:01 am

Re: Problem with image

Postby fantomasdm » Wed Mar 23, 2011 2:00 am

Hi at line 195 of xataface-1.2.6\Dataface\Application\blob.php
I have change
Code: Select all
if ( $fh = fopen($found, "w")  ){

to
Code: Select all
if ( $found!="" and $fh = fopen($found, "w")  ){

to prevent warning message
fantomasdm
 
Posts: 114
Joined: Thu Mar 13, 2008 2:35 pm

Re: Problem with image

Postby shannah » Wed Mar 23, 2011 10:27 am

Fixed in SVN rev 2071. Will be included in next release.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 6 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved