Page 1 of 1

PostPosted: Thu Sep 13, 2007 12:54 am
by siainmi
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').'">';
}
}

PostPosted: Thu Sep 13, 2007 1:02 am
by siainmi
sorry I send before finish!

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

but I can see nothing!

PostPosted: Thu Sep 13, 2007 9:12 am
by shannah

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';
ÊÊÊ ÊÊ Ê}


Ê ÊÊ


PostPosted: Mon Sep 24, 2007 5:36 am
by siainmi
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!

PostPosted: Mon Sep 24, 2007 5:58 am
by siainmi
if I put fopen("e:\\tmp\Scrive.txt","w"); before blob.php line 174 that file is create correctly

PostPosted: Mon Sep 24, 2007 5:35 pm
by shannah
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

PostPosted: Tue Sep 25, 2007 8:00 am
by siainmi
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!!

PostPosted: Tue Sep 25, 2007 8:08 am
by shannah
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

PostPosted: Thu Sep 27, 2007 7:36 am
by siainmi
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

PostPosted: Thu Feb 28, 2008 9:10 pm
by Paul
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

PostPosted: Thu Mar 26, 2009 2:29 am
by fantomasdm
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 "?", ":" ????

PostPosted: Thu Mar 26, 2009 8:45 am
by fantomasdm
with add this line it's work
$found=str_replace("?","-",$found);

Re: Problem with image

PostPosted: Wed Mar 10, 2010 2:55 am
by inmisia
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??

Re: Problem with image

PostPosted: Wed Mar 23, 2011 2:00 am
by fantomasdm
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

Re: Problem with image

PostPosted: Wed Mar 23, 2011 10:27 am
by shannah
Fixed in SVN rev 2071. Will be included in next release.