<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=text/html;charset=iso-8859-1 http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18812"></HEAD>
<BODY style="PADDING-LEFT: 10px; PADDING-RIGHT: 10px; PADDING-TOP: 15px" 
id=MailContainerBody leftMargin=0 topMargin=0 bgColor=#ffffff 
CanvasTabStop="true" name="Compose message area">
<DIV><FONT size=2 face=Arial>I risultati non sono positivi, ho provato con 
questo file.pl a caricare immagini sul database MySQL.</FONT></DIV>
<DIV><FONT size=2 face=Arial>#!/usr/bin/perl -w<BR>use warnings;<BR>use 
strict;<BR>use File::Slurp qw( read_file );<BR>use CGI qw( :standard );<BR>use 
DBI;<BR># Which database and which file from the filesystem?<BR>my $myfile = 
"picture10.png";<BR>my $dbname = "foto";<BR></FONT></DIV>
<DIV><FONT size=2 face=Arial># Make a connection to your database<BR>my $dbh = 
DBI-&gt;connect("dbi:mysql:database=$dbname") || die "Cannot open 
db";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial># Open the file<BR>open MYFILE, $myfile&nbsp; or 
die "Cannot open file";<BR>my $data;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial># Read in the contents<BR>while (&lt;MYFILE&gt;) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $data .= 
$_;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>close MYFILE;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>my $sql = "INSERT INTO fotograf (imagefoto) VALUES 
(?)";<BR>my $sth = $dbh-&gt;prepare($sql);<BR>my $numrows = 
$sth-&gt;execute($data);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial># We are done with the statement 
handle<BR>$sth-&gt;finish;<BR># I am finished with this connection to the 
database<BR>$dbh-&gt;disconnect;</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>$sql = "SELECT imagefoto&nbsp;FROM 
fotograf";<BR>$sth = $dbh-&gt;prepare($sql);<BR>$numrows = 
$sth-&gt;execute;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>open OUTPUT, "&gt;output.png";<BR>my $ref = 
$sth-&gt;fetchrow_hashref;<BR>my $newdata = $$ref{'imagefoto'};<BR>print OUTPUT 
$newdata;<BR>close 
OUTPUT;<BR>$sth-&gt;finish;<BR>$dbh-&gt;disconnect;<BR>======================================</FONT></DIV>
<DIV><FONT size=2 face=Arial>#mysql=====================================<BR>drop 
database IF EXISTS foto;<BR>CREATE DATABASE foto;<BR>use foto;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>CREATE TABLE fotograf (<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
id tinyint(3) unsigned NOT NULL auto_increment,<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
imagefoto blob NOT NULL,<BR>&nbsp;&nbsp;&nbsp;&nbsp; PRIMARY KEY 
(id)<BR>&nbsp;&nbsp;&nbsp;&nbsp; );<BR></FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>Mi aspetto di vedere l'immagine nella pagina 
html</FONT></DIV>
<DIV><FONT size=2 face=Arial>ma non c'è.</FONT></DIV>
<DIV><FONT size=2 face=Arial>saluti</DIV></FONT>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV style="FONT: 10pt Tahoma">
<DIV><BR></DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A 
title="mailto:polettix@gmail.com&#10;Ctrl + clic per seguire il collegamento" 
href="mailto:polettix@gmail.com">Flavio Poletti</A> </DIV>
<DIV><B>Sent:</B> Thursday, September 17, 2009 8:24 AM</DIV>
<DIV><B>To:</B> <A 
title="mailto:roma@pm.org&#10;Ctrl + clic per seguire il collegamento" 
href="mailto:roma@pm.org">roma@pm.org</A> </DIV>
<DIV><B>Subject:</B> Re: [Roma.pm] domanda</DIV></DIV></DIV>
<DIV><BR></DIV>1. non hai detto se ci sono stati risultati positivi con quanto 
suggerito nell'email precedente 
<DIV>2. non è chiaro come *estrai* l'immagine da MySQL e come fai a dire che 
"qualcosa non va". Ad esempio: usi un altro script in Perl? Fai un accesso con 
qualche altro strumento/linguaggio in modo da garantirti? Se usi uno script Perl 
posta anche quello.</DIV>
<DIV>3. ancora non ho capito di preciso *cosa* non vada<BR><BR>
<DIV class=gmail_quote>2009/9/17 <SPAN dir=ltr>&lt;<A 
href="mailto:umbertobernardelli@live.it">umbertobernardelli@live.it</A>&gt;</SPAN><BR>
<BLOCKQUOTE 
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" 
class=gmail_quote>
  <DIV style="PADDING-LEFT: 10px; PADDING-RIGHT: 10px; PADDING-TOP: 15px" 
  name="Compose message area" bgcolor="#ffffff">
  <DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
  <DIV style="FONT: 10pt Tahoma">
  <DIV><BR></DIV>
  <DIV style="BACKGROUND: #f5f5f5">
  <DIV><B>From:</B> <A 
  title="mailto:polettix@gmail.com&#13;&#10;Ctrl + clic per seguire il collegamento" 
  href="mailto:polettix@gmail.com" target=_blank>Flavio Poletti</A> </DIV>
  <DIV><B>Sent:</B> Wednesday, September 16, 2009 2:02 AM</DIV>
  <DIV class=im>
  <DIV><B>To:</B> <A title=roma@pm.org href="mailto:roma@pm.org" 
  target=_blank>roma@pm.org</A> </DIV>
  <DIV><B>Subject:</B> Re: [Roma.pm] domanda</DIV></DIV></DIV></DIV>
  <DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT size=2 face=Arial>utilizzo Widows XP professional&nbsp; e ho 
  aggiunto il server IIS:</FONT></DIV>
  <DIV><FONT size=2 face=Arial>il mio scopo è salvare l'immagine su MySQL e dopo 
  con GD::Image fare un confronto</FONT></DIV>
  <DIV><FONT size=2 face=Arial>con un'altra immagine.</FONT></DIV>
  <DIV><FONT size=2 face=Arial>Ciao</FONT></DIV>
  <DIV><FONT size=2 
  face=Arial>****************************************************************************</FONT></DIV>
  <DIV class=im>
  <DIV><BR></DIV>Continuo a non capire quali siano le difficoltà, visto che "DBI 
  funziona, con Mysql funziona". 
  <DIV><BR></DIV>
  <DIV>Non vorrei che il problema fosse altrove, comunque. Su che sistema ti 
  trovi? Se Windows, la lettura del file è errata perché devi impostare binmode 
  (non fa male farlo nel caso generale, comunque). Consiglio anche di utilizzare 
  filehandle con variabili lessicali e la versione a tre parametri di open(). 
  Insomma:</DIV>
  <DIV><BR></DIV>
  <DIV>my $data;</DIV>
  <DIV>{ # restringo lo scope</DIV>
  <DIV>&nbsp;&nbsp; local $/; # per leggere il file tutto in una volta</DIV>
  <DIV>&nbsp;&nbsp; open my $fh, '&lt;', $myfile</DIV>
  <DIV>&nbsp;&nbsp; &nbsp; &nbsp;or die "open('$myfile'): $!";</DIV>
  <DIV>&nbsp;&nbsp; binmode $fh;</DIV>
  <DIV>&nbsp;&nbsp; $data = &lt;$fh&gt;;</DIV>
  <DIV>&nbsp;&nbsp; close $fh;</DIV>
  <DIV>}</DIV>
  <DIV><BR></DIV>
  <DIV>che spesso puoi trovare "riassunto" come segue:</DIV>
  <DIV><BR></DIV>
  <DIV>my $data = do { open my $fh, '&lt;', $myfile or die "open(): $!"; binmode 
  $fh; local $/; &lt;$fh&gt; };</DIV>
  <DIV><BR></DIV>
  <DIV><BR></DIV>
  <DIV>In questi casi è molto comodo utilizzare File::Slurp:</DIV>
  <DIV><BR></DIV>
  <DIV>use File::Slurp qw( read_file );</DIV>
  <DIV>my $data = read_file($myfile); # voilà</DIV>
  <DIV><BR></DIV>
  <DIV><BR></DIV>
  <DIV>In questo modo, sei sicuro che non vengano operate trasformazioni sui 
  dati in ingresso quando leggi da file.</DIV>
  <DIV><BR></DIV>
  <DIV>Da notare che impostando $/ ad undef (quando fai "local" per default il 
  valore inserito è proprio undef) praticamente stai dicendo che il separatore 
  dei "record d'ingresso" è non definito, per cui Perl tratta l'intero file come 
  un 'record' e te lo legge tutto in una botta.</DIV>
  <DIV><BR></DIV>
  <DIV>Altra cosa... ma come controlli che il contenuto del blob corrisponda a 
  quello che ti aspetti?!?</DIV>
  <DIV><BR></DIV>
  <DIV>Ciao,</DIV>
  <DIV><BR></DIV>
  <DIV>&nbsp;&nbsp; &nbsp;Flavio.</DIV>
  <DIV><BR>&nbsp;</DIV></DIV></DIV><BR>_______________________________________________<BR>Roma 
  mailing list<BR><A href="mailto:Roma@pm.org">Roma@pm.org</A><BR><A 
  href="http://mail.pm.org/mailman/listinfo/roma" 
  target=_blank>http://mail.pm.org/mailman/listinfo/roma</A><BR></BLOCKQUOTE></DIV><BR></DIV>
<P>
<HR>

<P></P>_______________________________________________<BR>Roma mailing 
list<BR>Roma@pm.org<BR>http://mail.pm.org/mailman/listinfo/roma</BODY></HTML>