473,756 Members | 6,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

move_uploaded_f ile lose variables

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=$p ercorso.$_POST['Logo'];
$nuovo_nome1=$p ercorso.$_POST['Foto'];

$insertSQL = sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca_,
LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,
%s, %s, %s)",
GetSQLValueStri ng($_POST['ID_MarcaLinea'],
"int"),
GetSQLValueStri ng($_POST['Marca_'], "int"),
GetSQLValueStri ng($_POST['LineaProdotto_ '],
"int"),
GetSQLValueStri ng($nuovo_nome0 , "text"),
GetSQLValueStri ng($nuovo_nome1 , "text"),
GetSQLValueStri ng($_POST['Descrizione'],
"text"),
GetSQLValueStri ng($_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($in sertSQL, $Conn_Bianchi) or
die(mysql_error ());

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

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

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

############### ############### #
$insertGoTo = "view.php";
etc...
Nov 23 '07 #1
7 2083
Is the directory the system is writing the file to set with the
correct permissions?

On Nov 23, 10:37 am, nicemot...@gmai l.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=$p ercorso.$_POST['Logo'];
$nuovo_nome1=$p ercorso.$_POST['Foto'];

$insertSQL = sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca_,
LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,
%s, %s, %s)",
GetSQLValueStri ng($_POST['ID_MarcaLinea'],
"int"),
GetSQLValueStri ng($_POST['Marca_'], "int"),
GetSQLValueStri ng($_POST['LineaProdotto_ '],
"int"),
GetSQLValueStri ng($nuovo_nome0 , "text"),
GetSQLValueStri ng($nuovo_nome1 , "text"),
GetSQLValueStri ng($_POST['Descrizione'],
"text"),
GetSQLValueStri ng($_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($in sertSQL, $Conn_Bianchi) or
die(mysql_error ());

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

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

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

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

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

Nov 23 '07 #2
On 23 Nov, 17:46, Acrobatic <jbn...@gmail.c omwrote:
Is the directory the system is writing the file to set with the
correct permissions?

On Nov 23, 10:37 am, nicemot...@gmai l.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=$p ercorso.$_POST['Logo'];
$nuovo_nome1=$p ercorso.$_POST['Foto'];
$insertSQL = sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca_,
LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,
%s, %s, %s)",
GetSQLValueStri ng($_POST['ID_MarcaLinea'],
"int"),
GetSQLValueStri ng($_POST['Marca_'], "int"),
GetSQLValueStri ng($_POST['LineaProdotto_ '],
"int"),
GetSQLValueStri ng($nuovo_nome0 , "text"),
GetSQLValueStri ng($nuovo_nome1 , "text"),
GetSQLValueStri ng($_POST['Descrizione'],
"text"),
GetSQLValueStri ng($_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($in sertSQL, $Conn_Bianchi) or
die(mysql_error ());
////Everything ok 'till here; the following does't works:
######### upload image########
move_uploaded_f ile($file_temp0 , $nuovo_nome0);
move_uploaded_f ile($_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
Nov 23 '07 #3
On Fri, 23 Nov 2007 17:37:28 +0100, <ni********@gma il.comwrote:
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/feature...oad.errors.php
--
Rik Wasmus
Nov 23 '07 #4
On 23 Nov, 17:59, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Fri, 23 Nov 2007 17:37:28 +0100, <nicemot...@gma il.comwrote:
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.p hp
--
Rik Wasmus
Many thanks Rik,

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

.......... GetSQLValueStri ng($nuovo_nome1 , "text"),
GetSQLValueStri ng($_POST['Descrizione'],
"text"),
GetSQLValueStri ng($_POST['Pdf_'], "int"));
$errore=($_FILE S['Logo']['tmp_name']['error']);

print($errore);
mysql_select_db ($database..... ......
However i'm afraid (almost sure) i'm not using "" $_FILES['indexname']
['error'] "" correctly
Nov 23 '07 #5
On Fri, 23 Nov 2007 18:26:55 +0100, <ni********@gma il.comwrote:
On 23 Nov, 17:59, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
>On Fri, 23 Nov 2007 17:37:28 +0100, <nicemot...@gma il.comwrote:
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.p hp
written like this returns nothing , the record is inserted but the
pics are not uploaded.

......... GetSQLValueStri ng($nuovo_nome1 , "text"),
GetSQLValueStri ng($_POST['Descrizione'],
"text"),
GetSQLValueStri ng($_POST['Pdf_'], "int"));
$errore=($_FILE S['Logo']['tmp_name']['error']);

print($errore);

However i'm afraid (almost sure) i'm not using "" $_FILES['indexname']
['error'] "" correctly
What does var_dump($_FILE S); tell you? 'Logo' might not even be there.....
--
Rik Wasmus
Nov 23 '07 #6
On 23 Nov, 18:31, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Fri, 23 Nov 2007 18:26:55 +0100, <nicemot...@gma il.comwrote:
On 23 Nov, 17:59, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Fri, 23 Nov 2007 17:37:28 +0100, <nicemot...@gma il.comwrote:
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.p hp
written like this returns nothing , the record is inserted but the
pics are not uploaded.
......... GetSQLValueStri ng($nuovo_nome1 , "text"),
GetSQLValueStri ng($_POST['Descrizione'],
"text"),
GetSQLValueStri ng($_POST['Pdf_'], "int"));
$errore=($_FILE S['Logo']['tmp_name']['error']);
print($errore);
However i'm afraid (almost sure) i'm not using "" $_FILES['indexname']
['error'] "" correctly

What does var_dump($_FILE S); 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
Nov 23 '07 #7
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:

<form action="..." method="post" enctype="multip art/form-data"
name="...">

etc

</form>
On Nov 23, 10:37 am, nicemot...@gmai l.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=$p ercorso.$_POST['Logo'];
$nuovo_nome1=$p ercorso.$_POST['Foto'];

$insertSQL = sprintf("INSERT INTO marcalinea (ID_MarcaLinea, Marca_,
LineaProdotto_, Logo, Foto, Descrizione, Pdf_) VALUES (%s, %s, %s, %s,
%s, %s, %s)",
GetSQLValueStri ng($_POST['ID_MarcaLinea'],
"int"),
GetSQLValueStri ng($_POST['Marca_'], "int"),
GetSQLValueStri ng($_POST['LineaProdotto_ '],
"int"),
GetSQLValueStri ng($nuovo_nome0 , "text"),
GetSQLValueStri ng($nuovo_nome1 , "text"),
GetSQLValueStri ng($_POST['Descrizione'],
"text"),
GetSQLValueStri ng($_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($in sertSQL, $Conn_Bianchi) or
die(mysql_error ());

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

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

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

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

$insertGoTo = "view.php";
etc...
Nov 23 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
7646
by: neo002244 | last post by:
The move_uploaded_file() function is very quirky. I want to allow users to upload images to the Web site. Here is the code: if(!move_uploaded_file($_FILES, $imagefile)) { die("Could not move file: ".$_FILES." -> $imagefile"); } else { enter record into database...
1
3017
by: Felix Natter | last post by:
hi, I would like to upload a file (via a form), then read that (temporary) file and write the contents into a database. The first problem is that open_basedir=/home/CUSTOMER so I can't just read it from /tmp. That's why I used move_uploaded_file() to move the file to /home/CUSTOMER/DOMAIN/tmp/FILENAME: ======================================================
1
10682
by: sa | last post by:
Trying to upload a file using win xp/iis/php. I've given full access to all accounts trying to get this to work? Yet I'm still getting read errors. Simplified the script below to the bare minimum. simpleupload.php <form enctype="multipart/form-data" action="upload.php" method="post"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="200000"/>
6
3374
by: Stijn Goris | last post by:
HI all, I have created a script that allows a user to upload a picture. I have an IIS server runing on my own pc but the actual site runs an Apache server. The upload script worked perfectly on my IIS but refuses to work on the Apache. All I know is that the script stops working at move_uploaded_file() function. The warnings echo'ed are: Warning: move_uploaded_file(images/nieuws/TIDEEY%7E1.jpg): failed to open
2
16298
by: Brian | last post by:
Hi I am moving a site to a new server, I have been testing it and one of the pages uses move_uploaded_file, but I get a Permission denied. The directory I am moving it to is chomd of 755, if I change it to 777 it does upload but the owner is www-data, but I then can't download it using a FTP client (which I have to do) as it's the wrong owner, so I have to leave the chomd as 755, but
10
1715
by: Michael SL | last post by:
I have been using session variables in my asp.net application without any trouble. But now in a very specific case I am losing them. On one of my pages I set a date in a dropdownlist (autopostback=false) and then click a "Build" button which builds a report. Most of the time there is no problem. But sometimes the following happens. I step through the code no problem, the session variables do not change. But, when examined after the the...
8
6846
by: Simone Chiaretta | last post by:
I've a very strange behaveour related to a website we built: from times to times, something should happen on the server, and all static variables inside the web application, both defined inside aspx code-behind and in business logic (C# classes used by the aspx) lose their value. I cannot reproduce this on our development server, so I cannot understand what the cause of all this is. We are using asp.net 1.1 with IIS6 on win2003.
1
4237
by: comp.lang.php | last post by:
Consider my code: if ($this->isSuccessful && is_file($_FILES)) { // STEP 6: MOVE RESUME TO DIRECTORY $uuid = $this->sfug->getUUID(); if (!$uuid) $this->sfug->setUUID(); $uuid = $this->sfug->getUUID();
5
3373
by: bill | last post by:
I can validate that the file uploaded because is_uploaded_file() returns true. --------- if (is_uploaded_file($_FILES)) { echo "File ". $_FILES ." uploaded successfully.<br />"; } ------------------------ When I try to move the file using move_uploaded_file it fails. --------------
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.