[PHP] uploading help please again
Ok I'm back This script is to upload 2 image files Whit register_globals = on it Works fine script A p.php titleJornal O Leme/title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body bgcolor=#006699 table width=100% border=0 cellpadding=0 cellspacing=0 !--DWLayoutTable-- tr td width=100% height=70 valign=topimg src=test.jpg width=600 height=120 /td /tr tr td height=262 valign=toppnbsp;/p form method=post action=pi.php enctype=multipart/form-data table width=75% border=0 align=center bgcolor=#FF tr td width=23%div align=centerfont face=BankGothic Md BT /font/div/td td width=77% bgcolor=#FFnbsp; /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tddiv align=leftstrongImagem pequena/strong/div/td td bgcolor=#FF input type=hidden name=MAX_FILE_SIZE value=102400 input type=File name=origem /td /tr tr tddiv align=leftstrongImagem grande/strong/div/td td bgcolor=#FFinput type=hidden name=MAX_FILE_SIZE value=102400 input type=File name=origem2 /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tdnbsp;/td tdnbsp;/td /tr /table p align=center input name=submit type=submit value=Adicionar input type=hidden name=page value=inserir1 /form/p /td /tr tr td height=81 valign=topdiv align=center pnbsp;/p p ?php include ('menu.php'); ? nbsp;/p /div/td /tr /table pi.php echo $page; --- returns inserir1 _correct echo $origem; --- returns the temp path of the file _correct set_time_limit(60); $path=(dirname($PATH_TRANSLATED))./primeirapagina/; $origem_name=fdx.jpg; $dest= $path.$origem_name; if (($origem none) ($origem )){ if (copy($origem,$dest)){; } else { echo directoria sem direitos de escrita br; } unlink ($origem); } set_time_limit(60); $path2=(dirname($PATH_TRANSLATED))./primeirapagina/; $origem2_name=porra.jpg; $dest2= $path2.$origem2_name; //printf($path); //printf(br); //printf($origem_name); if (($origem2 none) ($origem2 )){ if (copy($origem2,$dest2)){; //echo brupload do ficheiro $origem_name efectuada com sucesso !!!; // echo brtamanho do ficheiro $origem_size; // echo brtipo de ficheiro $origem_type; } else { echo directoria sem direitos de escrita br; } unlink ($origem2); } ? /body /html but Whit register_globals = off the script B dont work script B: p.php titleJornal O Leme/title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body bgcolor=#006699 table width=100% border=0 cellpadding=0 cellspacing=0 !--DWLayoutTable-- tr td width=100% height=70 valign=topimg src=test.jpg width=600 height=120 /td /tr tr td height=262 valign=toppnbsp;/p form method=post action=pi.php enctype=multipart/form-data table width=75% border=0 align=center bgcolor=#FF tr td width=23%div align=centerfont face=BankGothic Md BT /font/div/td td width=77% bgcolor=#FFnbsp; /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tddiv align=leftstrongImagem pequena/strong/div/td td bgcolor=#FF input type=hidden name=MAX_FILE_SIZE value=102400 input type=File name=origem /td /tr tr tddiv align=leftstrongImagem grande/strong/div/td td bgcolor=#FFinput type=hidden name=MAX_FILE_SIZE value=102400 input type=File name=origem2 /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tdnbsp;/td tdnbsp;/td /tr /table p align=center input name=submit type=submit value=Adicionar input type=hidden name=page value=inserir1 /form/p /td /tr tr td height=81 valign=topdiv align=center pnbsp;/p p ?php include ('menu.php'); ? nbsp;/p /div/td /tr /table pi.php echo $_REQUEST['page']; returns inserir1 _correct echo $_FILES['origem']; returns ARRAY
RE: [PHP] uploading help please again
That's because $_FILES['origem'] is an array. It will have the following elements, where 'userfile' is 'origem' in your case: $_FILES['userfile']['name'] The original name of the file on the client machine. $_FILES['userfile']['type'] The mime type of the file, if the browser provided this information. An example would be image/gif. $_FILES['userfile']['size'] The size, in bytes, of the uploaded file. $_FILES['userfile']['tmp_name'] The temporary filename of the file in which the uploaded file was stored on the server. $_FILES['userfile']['error'] The error code associated with this file upload. ['error'] was added in PHP 4.2.0 Note: In PHP versions prior 4.1.0 this was named $HTTP_POST_FILES and it's not an autoglobal variable like $_FILES is. PHP 3 does not support $HTTP_POST_FILES. When register_globals is turned on in php.ini, additional variables are available. For example, $userfile_name will equal $_FILES['userfile']['name'], $userfile_type will equal $_FILES['userfile']['type'], etc. Keep in mind that as of PHP 4.2.0, register_globals defaults to off. It's preferred to not rely on this directive. ---John Holmes... -Original Message- From: marcelo [mailto:msalvador;sinesdigital.pt] Sent: Sunday, November 03, 2002 8:32 PM To: [EMAIL PROTECTED] Subject: [PHP] uploading help please again Ok I'm back This script is to upload 2 image files Whit register_globals = on it Works fine script A p.php titleJornal O Leme/title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body bgcolor=#006699 table width=100% border=0 cellpadding=0 cellspacing=0 !--DWLayoutTable-- tr td width=100% height=70 valign=topimg src=test.jpg width=600 height=120 /td /tr tr td height=262 valign=toppnbsp;/p form method=post action=pi.php enctype=multipart/form-data table width=75% border=0 align=center bgcolor=#FF tr td width=23%div align=centerfont face=BankGothic Md BT /font/div/td td width=77% bgcolor=#FFnbsp; /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tddiv align=leftstrongImagem pequena/strong/div/td td bgcolor=#FF input type=hidden name=MAX_FILE_SIZE value=102400 input type=File name=origem /td /tr tr tddiv align=leftstrongImagem grande/strong/div/td td bgcolor=#FFinput type=hidden name=MAX_FILE_SIZE value=102400 input type=File name=origem2 /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tdnbsp;/td tdnbsp;/td /tr /table p align=center input name=submit type=submit value=Adicionar input type=hidden name=page value=inserir1 /form/p /td /tr tr td height=81 valign=topdiv align=center pnbsp;/p p ?php include ('menu.php'); ? nbsp;/p /div/td /tr /table -- -- pi.php echo $page; --- returns inserir1 _correct echo $origem; --- returns the temp path of the file _correct set_time_limit(60); $path=(dirname($PATH_TRANSLATED))./primeirapagina/; $origem_name=fdx.jpg; $dest= $path.$origem_name; if (($origem none) ($origem )){ if (copy($origem,$dest)){; } else { echo directoria sem direitos de escrita br; } unlink ($origem); } set_time_limit(60); $path2=(dirname($PATH_TRANSLATED))./primeirapagina/; $origem2_name=porra.jpg; $dest2= $path2.$origem2_name; //printf($path); //printf(br); //printf($origem_name); if (($origem2 none) ($origem2 )){ if (copy($origem2,$dest2)){; //echo brupload do ficheiro $origem_name efectuada com sucesso !!!; // echo brtamanho do ficheiro $origem_size; // echo brtipo de ficheiro $origem_type; } else { echo directoria sem direitos de escrita br; } unlink ($origem2); } ? /body /html but Whit register_globals = off the script B dont work script B: p.php titleJornal O Leme/title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body bgcolor=#006699 table width=100% border=0 cellpadding=0 cellspacing=0 !--DWLayoutTable-- tr td width=100% height=70 valign=topimg src=test.jpg width=600 height=120 /td /tr tr td height=262 valign=toppnbsp;/p form method=post action=pi.php enctype=multipart/form-data table width=75% border=0 align=center bgcolor=#FF tr
[PHP] re:[PHP] uploading help please again
You might receive 2 files throught upload, then the first file name should be $_FILES['origem'] ; and the second file name $_FILES['origem2'] ; To use the different variables you can use, peer John Holmes's answer, there aren't no full answer like this anywhere? to ask if file uploaded is ok uploaded_file() is better than you are doing and use move_uploaded_file() instead copy() and unset() ; like this : if (is_uploaded_file($_FILES['origem']) ) move_uploaded_file($_FILES['origem'], $dest) ; /* $path=(dirname($PATH_TRANSLATED))./primeirapagina/; $origem_name=fdx.jpg; $dest= $path.$origem_name; if (($origem none) ($origem )){ if (copy($origem,$dest)){; } else { echo directoria sem direitos de escrita br; } unlink ($origem); } - Original Message - From: 'marcelo' [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 04, 2002 12:46 PM Subject: RE: [PHP] uploading help please again Ok I'm back This script is to upload 2 image files Whit register_globals = on it Works fine script A p.php titleJornal O Leme/title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body bgcolor=#006699 table width=100% border=0 cellpadding=0 cellspacing=0 !--DWLayoutTable-- tr td width=100% height=70 valign=topimg src=test.jpg width=600 height=120 /td /tr tr td height=262 valign=toppnbsp;/p form method=post action=pi.php enctype=multipart/form-data table width=75% border=0 align=center bgcolor=#FF tr td width=23%div align=centerfont face=BankGothic Md BT /font/div/td td width=77% bgcolor=#FFnbsp; /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tddiv align=leftstrongImagem pequena/strong/div/td td bgcolor=#FF input type=hidden name=MAX_FILE_SIZE value=102400 input type=File name=origem /td /tr tr tddiv align=leftstrongImagem grande/strong/div/td td bgcolor=#FFinput type=hidden name=MAX_FILE_SIZE value=102400 input type=File name=origem2 /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tdnbsp;/td tdnbsp;/td /tr /table p align=center input name=submit type=submit value=Adicionar input type=hidden name=page value=inserir1 /form/p /td /tr tr td height=81 valign=topdiv align=center pnbsp;/p p ?php include ('menu.php'); ? nbsp;/p /div/td /tr /table pi.php echo $page; --- returns inserir1 _correct echo $origem; --- returns the temp path of the file _correct set_time_limit(60); $path=(dirname($PATH_TRANSLATED))./primeirapagina/; $origem_name=fdx.jpg; $dest= $path.$origem_name; if (($origem none) ($origem )){ if (copy($origem,$dest)){; } else { echo directoria sem direitos de escrita br; } unlink ($origem); } set_time_limit(60); $path2=(dirname($PATH_TRANSLATED))./primeirapagina/; $origem2_name=porra.jpg; $dest2= $path2.$origem2_name; file://printf($path); file://printf(br); file://printf($origem_name); if (($origem2 none) ($origem2 )){ if (copy($origem2,$dest2)){; file://echo brupload do ficheiro $origem_name efectuada com sucesso !!!; // echo brtamanho do ficheiro $origem_size; // echo brtipo de ficheiro $origem_type; } else { echo directoria sem direitos de escrita br; } unlink ($origem2); } ? /body /html but Whit register_globals = off the script B dont work script B: p.php titleJornal O Leme/title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body bgcolor=#006699 table width=100% border=0 cellpadding=0 cellspacing=0 !--DWLayoutTable-- tr td width=100% height=70 valign=topimg src=test.jpg width=600 height=120 /td /tr tr td height=262 valign=toppnbsp;/p form method=post action=pi.php enctype=multipart/form-data table width=75% border=0 align=center bgcolor=#FF tr td width=23%div align=centerfont face=BankGothic Md BT /font/div/td td width=77% bgcolor=#FFnbsp; /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tddiv align=center/div/td td bgcolor=#FFnbsp; /td /tr tr tddiv align=leftstrongImagem pequena/strong/div/td td bgcolor=#FF input type=hidden name=MAX_FILE_SIZE value=102400 input type
Re: [PHP] re:[PHP] uploading help please again
On Monday 04 November 2002 11:04, rija wrote: You might receive 2 files throught upload, then the first file name should be $_FILES['origem'] ; and the second file name $_FILES['origem2'] ; To use the different variables you can use, peer John Holmes's answer, there aren't no full answer like this anywhere? There's a perfectly good example in the manual that people should use and adapt instead of trying to write their own non-working upload forms. If they could just spend a couple of minutes searching the archives or even reading the manual, they could save themselved oodles of time and grief. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Getting into trouble is easy. -- D. Winkel and F. Prosser */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php