move_uploaded_file lose variables

move_uploaded_file lose variables

am 23.11.2007 17:37:28 von nicemotion

Hi all,

the following easy script correctly insert a record in the DB but is
not moving the images (Logo and Foto) to the server /foto folder.

can't understand why 'cause the script is easy and correct and i guess
it loses the $file_temp var (actually the printout of $file_temp0
return nothing)

i even tryed to write it repeating the parameters i/o using variables
but no results.

Anyone can help ?

Many thanks in advance

Nik

-----------------------------------

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
{

//// set variables
$file_temp0=($_FILES['Logo']['tmp_name']);
$file_temp1=($_FILES['Foto']['tmp_name']);

//folder of the image on the server
$percorso="foto/";


$nuovo_nome0=$percorso.$_POST['Logo'];
$nuovo_nome1=$percorso.$_POST['Foto'];

$insertSQL = sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca_,
LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,
%s, %s, %s)",
GetSQLValueString($_POST['ID_MarcaLinea'],
"int"),
GetSQLValueString($_POST['Marca_'], "int"),
GetSQLValueString($_POST['LineaProdotto_'],
"int"),
GetSQLValueString($nuovo_nome0, "text"),
GetSQLValueString($nuovo_nome1, "text"),
GetSQLValueString($_POST['Descrizione'],
"text"),
GetSQLValueString($_POST['Pdf_'], "int"));

//print ($file_temp0); // return nothings
//print ($nuovo_nome0); // returns correctly /foto/img_name


mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
$Result1 = mysql_query($insertSQL, $Conn_Bianchi) or
die(mysql_error());

////Everything ok 'till here; the following does't works:

######### upload image########

move_uploaded_file($file_temp0, $nuovo_nome0);
move_uploaded_file($_FILES["Foto"]["tmp_name"],"foto/" .
$_FILES["Foto"]["name"]);

###############################


$insertGoTo = "view.php";
etc...

Re: move_uploaded_file lose variables

am 23.11.2007 17:46:32 von Acrobatic

Is the directory the system is writing the file to set with the
correct permissions?

On Nov 23, 10:37 am, nicemot...@gmail.com wrote:
> Hi all,
>
> the following easy script correctly insert a record in the DB but is
> not moving the images (Logo and Foto) to the server /foto folder.
>
> can't understand why 'cause the script is easy and correct and i guess
> it loses the $file_temp var (actually the printout of $file_temp0
> return nothing)
>
> i even tryed to write it repeating the parameters i/o using variables
> but no results.
>
> Anyone can help ?
>
> Many thanks in advance
>
> Nik
>
> -----------------------------------
>
> if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
> {
>
> //// set variables
> $file_temp0=($_FILES['Logo']['tmp_name']);
> $file_temp1=($_FILES['Foto']['tmp_name']);
>
> //folder of the image on the server
> $percorso="foto/";
>
> $nuovo_nome0=$percorso.$_POST['Logo'];
> $nuovo_nome1=$percorso.$_POST['Foto'];
>
> $insertSQL = sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca_,
> LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,
> %s, %s, %s)",
> GetSQLValueString($_POST['ID_MarcaLinea'],
> "int"),
> GetSQLValueString($_POST['Marca_'], "int"),
> GetSQLValueString($_POST['LineaProdotto_'],
> "int"),
> GetSQLValueString($nuovo_nome0, "text"),
> GetSQLValueString($nuovo_nome1, "text"),
> GetSQLValueString($_POST['Descrizione'],
> "text"),
> GetSQLValueString($_POST['Pdf_'], "int"));
>
> //print ($file_temp0); // return nothings
> //print ($nuovo_nome0); // returns correctly /foto/img_name
>
> mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> $Result1 = mysql_query($insertSQL, $Conn_Bianchi) or
> die(mysql_error());
>
> ////Everything ok 'till here; the following does't works:
>
> ######### upload image########
>
> move_uploaded_file($file_temp0, $nuovo_nome0);
> move_uploaded_file($_FILES["Foto"]["tmp_name"],"foto/" .
> $_FILES["Foto"]["name"]);
>
> ###############################
>
> $insertGoTo = "view.php";
> etc...

Re: move_uploaded_file lose variables

am 23.11.2007 17:57:05 von nicemotion

On 23 Nov, 17:46, Acrobatic wrote:
> Is the directory the system is writing the file to set with the
> correct permissions?
>
> On Nov 23, 10:37 am, nicemot...@gmail.com wrote:
>
> > Hi all,
>
> > the following easy script correctly insert a record in the DB but is
> > not moving the images (Logo and Foto) to the server /foto folder.
>
> > can't understand why 'cause the script is easy and correct and i guess
> > it loses the $file_temp var (actually the printout of $file_temp0
> > return nothing)
>
> > i even tryed to write it repeating the parameters i/o using variables
> > but no results.
>
> > Anyone can help ?
>
> > Many thanks in advance
>
> > Nik
>
> > -----------------------------------
>
> > if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
> > {
>
> > //// set variables
> > $file_temp0=($_FILES['Logo']['tmp_name']);
> > $file_temp1=($_FILES['Foto']['tmp_name']);
>
> > //folder of the image on the server
> > $percorso="foto/";
>
> > $nuovo_nome0=$percorso.$_POST['Logo'];
> > $nuovo_nome1=$percorso.$_POST['Foto'];
>
> > $insertSQL = sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca_,
> > LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,
> > %s, %s, %s)",
> > GetSQLValueString($_POST['ID_MarcaLinea'],
> > "int"),
> > GetSQLValueString($_POST['Marca_'], "int"),
> > GetSQLValueString($_POST['LineaProdotto_'],
> > "int"),
> > GetSQLValueString($nuovo_nome0, "text"),
> > GetSQLValueString($nuovo_nome1, "text"),
> > GetSQLValueString($_POST['Descrizione'],
> > "text"),
> > GetSQLValueString($_POST['Pdf_'], "int"));
>
> > //print ($file_temp0); // return nothings
> > //print ($nuovo_nome0); // returns correctly /foto/img_name
>
> > mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> > $Result1 = mysql_query($insertSQL, $Conn_Bianchi) or
> > die(mysql_error());
>
> > ////Everything ok 'till here; the following does't works:
>
> > ######### upload image########
>
> > move_uploaded_file($file_temp0, $nuovo_nome0);
> > move_uploaded_file($_FILES["Foto"]["tmp_name"],"foto/" .
> > $_FILES["Foto"]["name"]);
>
> > ###############################
>
> > $insertGoTo = "view.php";
> > etc...

hi acrobatic! - many thanks for your ppt reply

yes, it is; all permission are ok and the script to upload the files
separately works correctly.

The problem rises when i insert the record and upload the image on the
same page...i'm afraid the var are lost somewhere

Re: move_uploaded_file lose variables

am 23.11.2007 17:59:33 von luiheidsgoeroe

On Fri, 23 Nov 2007 17:37:28 +0100, wrote:

> Hi all,
>
> the following easy script correctly insert a record in the DB but is
> not moving the images (Logo and Foto) to the server /foto folder.
>
> can't understand why 'cause the script is easy and correct and i guess
> it loses the $file_temp var (actually the printout of $file_temp0
> return nothing)
>
> i even tryed to write it repeating the parameters i/o using variables
> but no results.

Examine $_FILES['indexname']['error']
http://nl2.php.net/manual/en/features.file-upload.errors.php
--
Rik Wasmus

Re: move_uploaded_file lose variables

am 23.11.2007 18:26:55 von nicemotion

On 23 Nov, 17:59, "Rik Wasmus" wrote:
> On Fri, 23 Nov 2007 17:37:28 +0100, wrote:
> > Hi all,
>
> > the following easy script correctly insert a record in the DB but is
> > not moving the images (Logo and Foto) to the server /foto folder.
>
> > can't understand why 'cause the script is easy and correct and i guess
> > it loses the $file_temp var (actually the printout of $file_temp0
> > return nothing)
>
> > i even tryed to write it repeating the parameters i/o using variables
> > but no results.
>
> Examine $_FILES['indexname']['error']http://nl2.php.net/manual/en/fe atures.file-upload.errors.php
> --
> Rik Wasmus

Many thanks Rik,

written like this returns nothing , the record is inserted but the
pics are not uploaded.



.......... GetSQLValueString($nuovo_nome1, "text"),
GetSQLValueString($_POST['Descrizione'],
"text"),
GetSQLValueString($_POST['Pdf_'], "int"));


$errore=($_FILES['Logo']['tmp_name']['error']);

print($errore);


mysql_select_db($database...........


However i'm afraid (almost sure) i'm not using "" $_FILES['indexname']
['error'] "" correctly

Re: move_uploaded_file lose variables

am 23.11.2007 18:31:34 von luiheidsgoeroe

On Fri, 23 Nov 2007 18:26:55 +0100, wrote:
> On 23 Nov, 17:59, "Rik Wasmus" wrote:
>> On Fri, 23 Nov 2007 17:37:28 +0100, wrote:
>> > the following easy script correctly insert a record in the DB but i=
s
>> > not moving the images (Logo and Foto) to the server /foto folder.=

>>
>> > can't understand why 'cause the script is easy and correct and i gu=
ess
>> > it loses the $file_temp var (actually the printout of $file_temp0
>> > return nothing)
>>
>> > i even tryed to write it repeating the parameters i/o using variabl=
es
>> > but no results.
>>
>> Examine =

>> $_FILES['indexname']['error']http://nl2.php.net/manual/en/fe atures.fi=
le-upload.errors.php

> written like this returns nothing , the record is inserted but the
> pics are not uploaded.
>
> ......... GetSQLValueString($nuovo_nome1, "text"),
> GetSQLValueString($_POST['Descrizione'],
> "text"),
> GetSQLValueString($_POST['Pdf_'], "int"));
>
>
> $errore=3D($_FILES['Logo']['tmp_name']['error']);
>
> print($errore);
>
> However i'm afraid (almost sure) i'm not using "" $_FILES['indexname']=

> ['error'] "" correctly

What does var_dump($_FILES); tell you? 'Logo' might not even be there...=
..
-- =

Rik Wasmus

Re: move_uploaded_file lose variables

am 23.11.2007 18:45:47 von nicemotion

On 23 Nov, 18:31, "Rik Wasmus" wrote:
> On Fri, 23 Nov 2007 18:26:55 +0100, wrote:
> > On 23 Nov, 17:59, "Rik Wasmus" wrote:
> >> On Fri, 23 Nov 2007 17:37:28 +0100, wrote:
> >> > the following easy script correctly insert a record in the DB but is
> >> > not moving the images (Logo and Foto) to the server /foto folder.
>
> >> > can't understand why 'cause the script is easy and correct and i guess
> >> > it loses the $file_temp var (actually the printout of $file_temp0
> >> > return nothing)
>
> >> > i even tryed to write it repeating the parameters i/o using variables
> >> > but no results.
>
> >> Examine
> >> $_FILES['indexname']['error']http://nl2.php.net/manual/en/fe atures.file-upload.errors.php
> > written like this returns nothing , the record is inserted but the
> > pics are not uploaded.
>
> > ......... GetSQLValueString($nuovo_nome1, "text"),
> > GetSQLValueString($_POST['Descrizione'],
> > "text"),
> > GetSQLValueString($_POST['Pdf_'], "int"));
>
> > $errore=($_FILES['Logo']['tmp_name']['error']);
>
> > print($errore);
>
> > However i'm afraid (almost sure) i'm not using "" $_FILES['indexname']
> > ['error'] "" correctly
>
> What does var_dump($_FILES); tell you? 'Logo' might not even be there....
> --
> Rik Wasmus

Dear Rik,

tks for yr debug suggestions, i'll study and revert

What's strange is that print ($nuovo_nome0); returns correctly /foto/
img_name

...is the $file_temp0=($_FILES['Logo']['tmp_name']) that does't works

Btw, debug and revert

Ciao by now (dinner time !) eand thanks a lot

Re: move_uploaded_file lose variables

am 23.11.2007 19:31:49 von Acrobatic

Can we see the script/form that you specify the upload file with?
Maybe you don't have the ENCTYPE set correctly. You'll need to set
enctype to "multipart/form-data":

ie:

name="...">

etc




On Nov 23, 10:37 am, nicemot...@gmail.com wrote:
> Hi all,
>
> the following easy script correctly insert a record in the DB but is
> not moving the images (Logo and Foto) to the server /foto folder.
>
> can't understand why 'cause the script is easy and correct and i guess
> it loses the $file_temp var (actually the printout of $file_temp0
> return nothing)
>
> i even tryed to write it repeating the parameters i/o using variables
> but no results.
>
> Anyone can help ?
>
> Many thanks in advance
>
> Nik
>
> -----------------------------------
>
> if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
> {
>
> //// set variables
> $file_temp0=($_FILES['Logo']['tmp_name']);
> $file_temp1=($_FILES['Foto']['tmp_name']);
>
> //folder of the image on the server
> $percorso="foto/";
>
> $nuovo_nome0=$percorso.$_POST['Logo'];
> $nuovo_nome1=$percorso.$_POST['Foto'];
>
> $insertSQL = sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca_,
> LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,
> %s, %s, %s)",
> GetSQLValueString($_POST['ID_MarcaLinea'],
> "int"),
> GetSQLValueString($_POST['Marca_'], "int"),
> GetSQLValueString($_POST['LineaProdotto_'],
> "int"),
> GetSQLValueString($nuovo_nome0, "text"),
> GetSQLValueString($nuovo_nome1, "text"),
> GetSQLValueString($_POST['Descrizione'],
> "text"),
> GetSQLValueString($_POST['Pdf_'], "int"));
>
> //print ($file_temp0); // return nothings
> //print ($nuovo_nome0); // returns correctly /foto/img_name
>
> mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> $Result1 = mysql_query($insertSQL, $Conn_Bianchi) or
> die(mysql_error());
>
> ////Everything ok 'till here; the following does't works:
>
> ######### upload image########
>
> move_uploaded_file($file_temp0, $nuovo_nome0);
> move_uploaded_file($_FILES["Foto"]["tmp_name"],"foto/" .
> $_FILES["Foto"]["name"]);
>
> ###############################
>
> $insertGoTo = "view.php";
> etc...

Re: move_uploaded_file lose variables

am 24.11.2007 10:53:38 von nicemotion

On 23 Nov, 19:31, Acrobatic wrote:
> Can we see the script/form that you specify the upload file with?
> Maybe you don't have the ENCTYPE set correctly. You'll need to set
> enctype to "multipart/form-data":
>
> ie:
>
>

> name=3D"...">
>
> etc
>
>

>
> On Nov 23, 10:37 am, nicemot...@gmail.com wrote:
>
> > Hi all,
>
> > the following easy script correctly insert a record in the DB but is
> > not moving the images (Logo and Foto) to the server /foto folder.
>
> > can't understand why 'cause the script is easy and correct and i guess
> > it loses the $file_temp var (actually the printout of $file_temp0
> > return nothing)
>
> > i even tryed to write it repeating the parameters i/o using variables
> > but no results.
>
> > Anyone can help ?
>
> > Many thanks in advance
>
> > Nik
>
> > -----------------------------------
>
> > if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")=
)
> > {
>
> > //// set variables
> > $file_temp0=3D($_FILES['Logo']['tmp_name']);
> > $file_temp1=3D($_FILES['Foto']['tmp_name']);
>
> > //folder of the image on the server
> > $percorso=3D"foto/";
>
> > $nuovo_nome0=3D$percorso.$_POST['Logo'];
> > $nuovo_nome1=3D$percorso.$_POST['Foto'];
>
> > $insertSQL =3D sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca_,=

> > LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,
> > %s, %s, %s)",
> > GetSQLValueString($_POST['ID_MarcaLinea'],
> > "int"),
> > GetSQLValueString($_POST['Marca_'], "int"),
> > GetSQLValueString($_POST['LineaProdotto_'],
> > "int"),
> > GetSQLValueString($nuovo_nome0, "text"),
> > GetSQLValueString($nuovo_nome1, "text"),
> > GetSQLValueString($_POST['Descrizione'],
> > "text"),
> > GetSQLValueString($_POST['Pdf_'], "int"));
>
> > //print ($file_temp0); // return nothings
> > //print ($nuovo_nome0); // returns correctly /foto/img_name
>
> > mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> > $Result1 =3D mysql_query($insertSQL, $Conn_Bianchi) or
> > die(mysql_error());
>
> > ////Everything ok 'till here; the following does't works:
>
> > ######### upload image########
>
> > move_uploaded_file($file_temp0, $nuovo_nome0);
> > move_uploaded_file($_FILES["Foto"]["tmp_name"],"foto/" .
> > $_FILES["Foto"]["name"]);
>
> > ###############################
>
> > $insertGoTo =3D "view.php";
> > etc...

Hi Acrobat, this is the full script:


if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue =3D "",
$theNotDefinedValue =3D "")
{
$theValue =3D get_magic_quotes_gpc() ? stripslashes($theValue) :
$theValue;

$theValue =3D function_exists("mysql_real_escape_string") ?
mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue =3D ($theValue !=3D "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue =3D ($theValue !=3D "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue =3D ($theValue !=3D "") ? "'" . doubleval($theValue) .
"'" : "NULL";
break;
case "date":
$theValue =3D ($theValue !=3D "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue =3D ($theValue !=3D "") ? $theDefinedValue :
$theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction =3D $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .=3D "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
{

######Gestione Img###
$file_temp0=3D$_FILES['Logo']['tmp_name'];
$file_temp1=3D$_FILES['Foto']['tmp_name'];
$errore=3D$_FILES['Logo']['error'];
//file temporaneo che contiene l'immagine caricata
$percorso=3D"foto/";
//cartella sul server dove verr=E0 spostata la foto
$nuovo_nome0=3D$percorso.$_POST['Logo'];
$nuovo_nome1=3D$percorso.$_POST['Foto'];
#################

$insertSQL =3D sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca_,
LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,
%s, %s, %s)",
GetSQLValueString($_POST['ID_MarcaLinea'],
"int"),
GetSQLValueString($_POST['Marca_'], "int"),
GetSQLValueString($_POST['LineaProdotto_'],
"int"),
GetSQLValueString($nuovo_nome0, "text"),
GetSQLValueString($nuovo_nome1, "text"),
GetSQLValueString($_POST['Descrizione'],
"text"),
GetSQLValueString($_POST['Pdf_'], "int"));




print($errore);


mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
$Result1 =3D mysql_query($insertSQL, $Conn_Bianchi) or
die(mysql_error());

######### sposto l'immagine nella cartella ########
move_uploaded_file($_FILES["Logo"]["tmp_name"],"foto/" .
$_FILES["Logo"]["name"]);
move_uploaded_file($file_temp1, $nuovo_nome1);
###############################


$insertGoTo =3D "view.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .=3D (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .=3D $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
$query_QryGeneral =3D "SELECT * FROM lineeprodotto, marcalinea, marche
WHERE marcalinea.Marca_ =3D marche.ID_Marche AND
marcalinea.LineaProdotto_ =3D lineeprodotto.ID_Linee";
$QryGeneral =3D mysql_query($query_QryGeneral, $Conn_Bianchi) or
die(mysql_error());
$row_QryGeneral =3D mysql_fetch_assoc($QryGeneral);
$totalRows_QryGeneral =3D mysql_num_rows($QryGeneral);

mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
$query_QryMarche =3D "SELECT * FROM marche";
$QryMarche =3D mysql_query($query_QryMarche, $Conn_Bianchi) or
die(mysql_error());
$row_QryMarche =3D mysql_fetch_assoc($QryMarche);
$totalRows_QryMarche =3D mysql_num_rows($QryMarche);

mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
$query_QryLineaProdotto =3D "SELECT * FROM lineeprodotto";
$QryLineaProdotto =3D mysql_query($query_QryLineaProdotto,
$Conn_Bianchi) or die(mysql_error());
$row_QryLineaProdotto =3D mysql_fetch_assoc($QryLineaProdotto);
$totalRows_QryLineaProdotto =3D mysql_num_rows($QryLineaProdotto);

mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
$query_QryMarcaLinea =3D "SELECT * FROM marcalinea";
$QryMarcaLinea =3D mysql_query($query_QryMarcaLinea, $Conn_Bianchi) or
die(mysql_error());
$row_QryMarcaLinea =3D mysql_fetch_assoc($QryMarcaLinea);
$totalRows_QryMarcaLinea =3D mysql_num_rows($QryMarcaLinea);
?> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


charset=3Diso-8859-1" />
Documento senza titolo




>">































ID_MarcaLinea: > td>
Marca_:
LineaProdotto_:
Logo

:
Foto

:
Descrizione: <=
/
td>
Pdf_:
 




mysql_free_result($QryGeneral);

mysql_free_result($QryMarche);

mysql_free_result($QryLineaProdotto);

mysql_free_result($QryMarcaLinea);
?>

Re: move_uploaded_file lose variables

am 24.11.2007 10:59:49 von nicemotion

On 24 Nov, 10:53, nicemot...@gmail.com wrote:
> On 23 Nov, 19:31, Acrobatic wrote:
>
>
>
> > Can we see the script/form that you specify the upload file with?
> > Maybe you don't have the ENCTYPE set correctly. You'll need to set
> > enctype to "multipart/form-data":
>
> > ie:
>
> >

> > name=3D"...">
>
> > etc
>
> >

>
> > On Nov 23, 10:37 am, nicemot...@gmail.com wrote:
>
> > > Hi all,
>
> > > the following easy script correctly insert a record in the DB but is
> > > not moving the images (Logo and Foto) to the server /foto folder.
>
> > > can't understand why 'cause the script is easy and correct and i guess=

> > > it loses the $file_temp var (actually the printout of $file_temp0
> > > return nothing)
>
> > > i even tryed to write it repeating the parameters i/o using variables
> > > but no results.
>
> > > Anyone can help ?
>
> > > Many thanks in advance
>
> > > Nik
>
> > > -----------------------------------
>
> > > if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1=
"))
> > > {
>
> > > //// set variables
> > > $file_temp0=3D($_FILES['Logo']['tmp_name']);
> > > $file_temp1=3D($_FILES['Foto']['tmp_name']);
>
> > > //folder of the image on the server
> > > $percorso=3D"foto/";
>
> > > $nuovo_nome0=3D$percorso.$_POST['Logo'];
> > > $nuovo_nome1=3D$percorso.$_POST['Foto'];
>
> > > $insertSQL =3D sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca=
_,
> > > LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,=

> > > %s, %s, %s)",
> > > GetSQLValueString($_POST['ID_MarcaLinea'],
> > > "int"),
> > > GetSQLValueString($_POST['Marca_'], "int"),
> > > GetSQLValueString($_POST['LineaProdotto_'],
> > > "int"),
> > > GetSQLValueString($nuovo_nome0, "text"),
> > > GetSQLValueString($nuovo_nome1, "text"),
> > > GetSQLValueString($_POST['Descrizione'],
> > > "text"),
> > > GetSQLValueString($_POST['Pdf_'], "int"));
>
> > > //print ($file_temp0); // return nothings
> > > //print ($nuovo_nome0); // returns correctly /foto/img_name
>
> > > mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> > > $Result1 =3D mysql_query($insertSQL, $Conn_Bianchi) or
> > > die(mysql_error());
>
> > > ////Everything ok 'till here; the following does't works:
>
> > > ######### upload image########
>
> > > move_uploaded_file($file_temp0, $nuovo_nome0);
> > > move_uploaded_file($_FILES["Foto"]["tmp_name"],"foto/" .
> > > $_FILES["Foto"]["name"]);
>
> > > ###############################
>
> > > $insertGoTo =3D "view.php";
> > > etc...
>
> Hi Acrobat, this is the full script:
>
>
> > if (!function_exists("GetSQLValueString")) {
> function GetSQLValueString($theValue, $theType, $theDefinedValue =3D "",
> $theNotDefinedValue =3D "")
> {
> $theValue =3D get_magic_quotes_gpc() ? stripslashes($theValue) :
> $theValue;
>
> $theValue =3D function_exists("mysql_real_escape_string") ?
> mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
>
> switch ($theType) {
> case "text":
> $theValue =3D ($theValue !=3D "") ? "'" . $theValue . "'" : "NULL";
> break;
> case "long":
> case "int":
> $theValue =3D ($theValue !=3D "") ? intval($theValue) : "NULL";
> break;
> case "double":
> $theValue =3D ($theValue !=3D "") ? "'" . doubleval($theValue) .
> "'" : "NULL";
> break;
> case "date":
> $theValue =3D ($theValue !=3D "") ? "'" . $theValue . "'" : "NULL";
> break;
> case "defined":
> $theValue =3D ($theValue !=3D "") ? $theDefinedValue :
> $theNotDefinedValue;
> break;
> }
> return $theValue;
>
> }
> }
>
> $editFormAction =3D $_SERVER['PHP_SELF'];
> if (isset($_SERVER['QUERY_STRING'])) {
> $editFormAction .=3D "?" . htmlentities($_SERVER['QUERY_STRING']);
>
> }
>
> if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
> {
>
> ######Gestione Img###
> $file_temp0=3D$_FILES['Logo']['tmp_name'];
> $file_temp1=3D$_FILES['Foto']['tmp_name'];
> $errore=3D$_FILES['Logo']['error'];
> //file temporaneo che contiene l'immagine caricata
> $percorso=3D"foto/";
> //cartella sul server dove verr=E0 spostata la foto
> $nuovo_nome0=3D$percorso.$_POST['Logo'];
> $nuovo_nome1=3D$percorso.$_POST['Foto'];
> #################
>
> $insertSQL =3D sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca_,
> LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,
> %s, %s, %s)",
> GetSQLValueString($_POST['ID_MarcaLinea'],
> "int"),
> GetSQLValueString($_POST['Marca_'], "int"),
> GetSQLValueString($_POST['LineaProdotto_'],
> "int"),
> GetSQLValueString($nuovo_nome0,=
"text"),
> GetSQLValueString($nuovo_nome1, "text"),
> GetSQLValueString($_POST['Descrizione'],
> "text"),
> GetSQLValueString($_POST['Pdf_'], "int"));
>
> print($errore);
>
> mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> $Result1 =3D mysql_query($insertSQL, $Conn_Bianchi) or
> die(mysql_error());
>
> ######### sposto l'immagine nella cartella ########
> move_uploaded_file($_FILES["Logo"]["tmp_name"],"foto/" .
> $_FILES["Logo"]["name"]);
> move_uploaded_file($file_temp1, $nuovo_nome1);
> ###############################
>
> $insertGoTo =3D "view.php";
> if (isset($_SERVER['QUERY_STRING'])) {
> $insertGoTo .=3D (strpos($insertGoTo, '?')) ? "&" : "?";
> $insertGoTo .=3D $_SERVER['QUERY_STRING'];
> }
> header(sprintf("Location: %s", $insertGoTo));
>
> }
>
> mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> $query_QryGeneral =3D "SELECT * FROM lineeprodotto, marcalinea, marche
> WHERE marcalinea.Marca_ =3D marche.ID_Marche AND
> marcalinea.LineaProdotto_ =3D lineeprodotto.ID_Linee";
> $QryGeneral =3D mysql_query($query_QryGeneral, $Conn_Bianchi) or
> die(mysql_error());
> $row_QryGeneral =3D mysql_fetch_assoc($QryGeneral);
> $totalRows_QryGeneral =3D mysql_num_rows($QryGeneral);
>
> mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> $query_QryMarche =3D "SELECT * FROM marche";
> $QryMarche =3D mysql_query($query_QryMarche, $Conn_Bianchi) or
> die(mysql_error());
> $row_QryMarche =3D mysql_fetch_assoc($QryMarche);
> $totalRows_QryMarche =3D mysql_num_rows($QryMarche);
>
> mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> $query_QryLineaProdotto =3D "SELECT * FROM lineeprodotto";
> $QryLineaProdotto =3D mysql_query($query_QryLineaProdotto,
> $Conn_Bianchi) or die(mysql_error());
> $row_QryLineaProdotto =3D mysql_fetch_assoc($QryLineaProdotto);
> $totalRows_QryLineaProdotto =3D mysql_num_rows($QryLineaProdotto);
>
> mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> $query_QryMarcaLinea =3D "SELECT * FROM marcalinea";
> $QryMarcaLinea =3D mysql_query($query_QryMarcaLinea, $Conn_Bianchi) or
> die(mysql_error());
> $row_QryMarcaLinea =3D mysql_fetch_assoc($QryMarcaLinea);
> $totalRows_QryMarcaLinea =3D mysql_num_rows($QryMarcaLinea);
> ?> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
>
> > charset=3Diso-8859-1" />
> Documento senza titolo
>
>
>
>
?>">
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
ID_MarcaLinea: 2"> > td>
>
Marca_:
>
LineaProdotto_:
>
Logo
>
> :
Foto
>
> :
Descrizione: > > td>
>
Pdf_:
 
>

>

>
>
> > mysql_free_result($QryGeneral);
>
> mysql_free_result($QryMarche);
>
> mysql_free_result($QryLineaProdotto);
>
> mysql_free_result($QryMarcaLinea);
> ?>

what i don't understand is that if i pass the var Logo and Foto from a
separate form and modify the existing record it works !

means... the following works perfectly:


$foto_id=3D($_POST['record_ID']) ;

$NomefileOrig0 =3D $_FILES['Logo']['name'];
$NomefileOrig1 =3D $_FILES['Foto']['name'];


$file_temp0=3D($_FILES['Logo']['tmp_name']);
$file_temp1=3D($_FILES['Foto']['tmp_name']);


$percorso=3D"foto/";


$nuovo_nome0=3D$percorso.$NomefileOrig0;
$nuovo_nome1=3D$percorso.$NomefileOrig1;



$updateSQL =3D"UPDATE marcalinea SET
Logo=3D'$nuovo_nome0',Foto=3D'$nuovo_nome1' WHERE ID_MarcaLinea=3D$foto_id";=



mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);

$Result1 =3D mysql_query($updateSQL, $Conn_Bianchi) or
die(mysql_error());


move_uploaded_file($file_temp0, $nuovo_nome0);
move_uploaded_file($file_temp1, $nuovo_nome1);
header("Location:view.php");

?>

What a headache!

Re: move_uploaded_file lose variables

am 24.11.2007 14:29:59 von nicemotion

On 24 Nov, 10:59, nicemot...@gmail.com wrote:
> On 24 Nov, 10:53, nicemot...@gmail.com wrote:
>
>
>
> > On 23 Nov, 19:31, Acrobatic wrote:
>
> > > Can we see the script/form that you specify the upload file with?
> > > Maybe you don't have the ENCTYPE set correctly. You'll need to set
> > > enctype to "multipart/form-data":
>
> > > ie:
>
> > >

> > > name=3D"...">
>
> > > etc
>
> > >

>
> > > On Nov 23, 10:37 am, nicemot...@gmail.com wrote:
>
> > > > Hi all,
>
> > > > the following easy script correctly insert a record in the DB but is=

> > > > not moving the images (Logo and Foto) to the server /foto folder.
>
> > > > can't understand why 'cause the script is easy and correct and i gue=
ss
> > > > it loses the $file_temp var (actually the printout of $file_temp0
> > > > return nothing)
>
> > > > i even tryed to write it repeating the parameters i/o using variable=
s
> > > > but no results.
>
> > > > Anyone can help ?
>
> > > > Many thanks in advance
>
> > > > Nik
>
> > > > -----------------------------------
>
> > > > if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "for=
m1"))
> > > > {
>
> > > > //// set variables
> > > > $file_temp0=3D($_FILES['Logo']['tmp_name']);
> > > > $file_temp1=3D($_FILES['Foto']['tmp_name']);
>
> > > > //folder of the image on the server
> > > > $percorso=3D"foto/";
>
> > > > $nuovo_nome0=3D$percorso.$_POST['Logo'];
> > > > $nuovo_nome1=3D$percorso.$_POST['Foto'];
>
> > > > $insertSQL =3D sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Mar=
ca_,
> > > > LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %=
s,
> > > > %s, %s, %s)",
> > > > GetSQLValueString($_POST['ID_MarcaLinea'],
> > > > "int"),
> > > > GetSQLValueString($_POST['Marca_'], "int"),
> > > > GetSQLValueString($_POST['LineaProdotto_'],
> > > > "int"),
> > > > GetSQLValueString($nuovo_nome0, "text"),
> > > > GetSQLValueString($nuovo_nome1, "text"),
> > > > GetSQLValueString($_POST['Descrizione'],
> > > > "text"),
> > > > GetSQLValueString($_POST['Pdf_'], "int"));
>
> > > > //print ($file_temp0); // return nothings
> > > > //print ($nuovo_nome0); // returns correctly /foto/img_name
>
> > > > mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> > > > $Result1 =3D mysql_query($insertSQL, $Conn_Bianchi) or
> > > > die(mysql_error());
>
> > > > ////Everything ok 'till here; the following does't works:
>
> > > > ######### upload image########
>
> > > > move_uploaded_file($file_temp0, $nuovo_nome0);
> > > > move_uploaded_file($_FILES["Foto"]["tmp_name"],"foto/" .
> > > > $_FILES["Foto"]["name"]);
>
> > > > ###############################
>
> > > > $insertGoTo =3D "view.php";
> > > > etc...
>
> > Hi Acrobat, this is the full script:
>
> >
> > > > if (!function_exists("GetSQLValueString")) {
> > function GetSQLValueString($theValue, $theType, $theDefinedValue =3D "",=

> > $theNotDefinedValue =3D "")
> > {
> > $theValue =3D get_magic_quotes_gpc() ? stripslashes($theValue) :
> > $theValue;
>
> > $theValue =3D function_exists("mysql_real_escape_string") ?
> > mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
>
> > switch ($theType) {
> > case "text":
> > $theValue =3D ($theValue !=3D "") ? "'" . $theValue . "'" : "NULL"=
;
> > break;
> > case "long":
> > case "int":
> > $theValue =3D ($theValue !=3D "") ? intval($theValue) : "NULL";
> > break;
> > case "double":
> > $theValue =3D ($theValue !=3D "") ? "'" . doubleval($theValue) .
> > "'" : "NULL";
> > break;
> > case "date":
> > $theValue =3D ($theValue !=3D "") ? "'" . $theValue . "'" : "NULL"=
;
> > break;
> > case "defined":
> > $theValue =3D ($theValue !=3D "") ? $theDefinedValue :
> > $theNotDefinedValue;
> > break;
> > }
> > return $theValue;
>
> > }
> > }
>
> > $editFormAction =3D $_SERVER['PHP_SELF'];
> > if (isset($_SERVER['QUERY_STRING'])) {
> > $editFormAction .=3D "?" . htmlentities($_SERVER['QUERY_STRING']);
>
> > }
>
> > if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")=
)
> > {
>
> > ######Gestione Img###
> > $file_temp0=3D$_FILES['Logo']['tmp_name'];
> > $file_temp1=3D$_FILES['Foto']['tmp_name'];
> > $errore=3D$_FILES['Logo']['error'];
> > //file temporaneo che contiene l'immagine caricata
> > $percorso=3D"foto/";
> > //cartella sul server dove verr=E0 spostata la foto
> > $nuovo_nome0=3D$percorso.$_POST['Logo'];
> > $nuovo_nome1=3D$percorso.$_POST['Foto'];
> > #################
>
> > $insertSQL =3D sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca_,=

> > LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,
> > %s, %s, %s)",
> > GetSQLValueString($_POST['ID_MarcaLinea'],
> > "int"),
> > GetSQLValueString($_POST['Marca_'], "int"),
> > GetSQLValueString($_POST['LineaProdotto_'],
> > "int"),
> > GetSQLValueString($nuovo_nome=
0, "text"),
> > GetSQLValueString($nuovo_nome1, "text"),
> > GetSQLValueString($_POST['Descrizione'],
> > "text"),
> > GetSQLValueString($_POST['Pdf_'], "int"));
>
> > print($errore);
>
> > mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> > $Result1 =3D mysql_query($insertSQL, $Conn_Bianchi) or
> > die(mysql_error());
>
> > ######### sposto l'immagine nella cartella ########
> > move_uploaded_file($_FILES["Logo"]["tmp_name"],"foto/" .
> > $_FILES["Logo"]["name"]);
> > move_uploaded_file($file_temp1, $nuovo_nome1);
> > ###############################
>
> > $insertGoTo =3D "view.php";
> > if (isset($_SERVER['QUERY_STRING'])) {
> > $insertGoTo .=3D (strpos($insertGoTo, '?')) ? "&" : "?";
> > $insertGoTo .=3D $_SERVER['QUERY_STRING'];
> > }
> > header(sprintf("Location: %s", $insertGoTo));
>
> > }
>
> > mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> > $query_QryGeneral =3D "SELECT * FROM lineeprodotto, marcalinea, marche
> > WHERE marcalinea.Marca_ =3D marche.ID_Marche AND
> > marcalinea.LineaProdotto_ =3D lineeprodotto.ID_Linee";
> > $QryGeneral =3D mysql_query($query_QryGeneral, $Conn_Bianchi) or
> > die(mysql_error());
> > $row_QryGeneral =3D mysql_fetch_assoc($QryGeneral);
> > $totalRows_QryGeneral =3D mysql_num_rows($QryGeneral);
>
> > mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> > $query_QryMarche =3D "SELECT * FROM marche";
> > $QryMarche =3D mysql_query($query_QryMarche, $Conn_Bianchi) or
> > die(mysql_error());
> > $row_QryMarche =3D mysql_fetch_assoc($QryMarche);
> > $totalRows_QryMarche =3D mysql_num_rows($QryMarche);
>
> > mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> > $query_QryLineaProdotto =3D "SELECT * FROM lineeprodotto";
> > $QryLineaProdotto =3D mysql_query($query_QryLineaProdotto,
> > $Conn_Bianchi) or die(mysql_error());
> > $row_QryLineaProdotto =3D mysql_fetch_assoc($QryLineaProdotto);
> > $totalRows_QryLineaProdotto =3D mysql_num_rows($QryLineaProdotto);
>
> > mysql_select_db($database_Conn_Bianchi, $Conn_Bianchi);
> > $query_QryMarcaLinea =3D "SELECT * FROM marcalinea";
> > $QryMarcaLinea =3D mysql_query($query_QryMarcaLinea, $Conn_Bianchi) or
> > die(mysql_error());
> > $row_QryMarcaLinea =3D mysql_fetch_assoc($QryMarcaLinea);
> > $totalRows_QryMarcaLinea =3D mysql_num_rows($QryMarcaLinea);
> > ?> > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> >
> >
> > > > charset=3Diso-8859-1" />
> > Documento senza titolo
> >
>
> >
> >
n; ?>">
>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
ID_MarcaLinea: "32"> > > td>
> >
Marca_:
> >
LineaProdotto_:
> >
Logo
>
> > :
Foto
>
> > :
Descrizione: 2"> > > td>
> >
Pdf_: >
> >
 
> >

> >

> >
> >
> > > > mysql_free_result($QryGeneral);
>
> > mysql_free_result($QryMarche);
>
> > mysql_free_result($QryLineaProdotto);
>
> > mysql_free_result($QryMarcaLinea);
> > ?>
>


Solved: enctype=3D"multipart/form-data" was missed :((

tks anyway

Nik