This topic is locked
[SOLVED]

 Catching the uploaded file properties for a custom Add p

8/5/2010 4:06:36 AM
PHPRunner General questions
A
aptivus author

Hello everyone,

I have build an Add page that performs differently from the standard one but I have troubles with uploaded files.

I explain:
when I add a record (that includes also an image), in the "Before record added" events I put something like this

(it's a call at 2 stored procedures):

//global $conn;
$bacheca_query = "CALL BAC_CREATE_ADM_MESSAGE('IT','".$values['Titolo']."','".$values['Estratto']."',

'".mysql_real_escape_string($values['Contenuto'])."','".$values['url_picture']."','".$values['category']."',@titolo,@abstract,@testo,@id_messaggio)";
//db_exec($bacheca_query, $conn);
$inserisci_bacheca = mysql_query($bacheca_query);
$bacheca_en_queryT = "CALL TXT_SET_MESSAGE(@titolo,'".$values['TitoloEN']."','EN')";

$inserisci_bacheca_ingleseT = mysql_query($bacheca_en_queryT);
$bacheca_en_queryE = "CALL TXT_SET_MESSAGE(@abstract,'".$values['EstrattoEN']."','EN')";

$inserisci_bacheca_ingleseE = mysql_query($bacheca_en_queryE);
$bacheca_en_queryC = "CALL TXT_SET_MESSAGE(@testo,'".$values['ContenutoEN']."','EN')";

$inserisci_bacheca_ingleseC = mysql_query($bacheca_en_queryC);
if(($inserisci_bacheca)&&($inserisci_bacheca_ingleseT)&&($inserisci_bacheca_ingleseE)&&($inserisci_bacheca_ingleseC))

$message = "<div style='width:100%; padding: 15px; border:1px solid green; background-color:#d5f4df;text-align:center;'>

RECORD INSERT</div>";
return false;


The file uploaded should be:

$values['url_picture']


Naturally, even if I store the name of the file uploaded in the DB, actually I cannot upload it.

How do I intercept the filesize, the file type and so on, in order to build a function to upload it seamlessly?
Thank ou very much

J
Jane 8/5/2010

Hi,
here are some samples how to check file size and extension:

http://xlinesoft.com/phprunner/docs/check_size_and_extension_of_uploadfiles.htm

A
aptivus author 8/5/2010



Hi,
here are some samples how to check file size and extension:

http://xlinesoft.com/phprunner/docs/check_size_and_extension_of_uploadfiles.htm


Thank you very much Jane.

Just one more help if you can.

How should my upload code would be written?

I've tried something like this, before my calls to stored procedures:



move_uploaded_file($_FILES['file_url_picture']['tmp_name'],"files/" . $_FILES['file_url_picture']['name']);


but it doesn't work.

Any hint?

Thanks again

J
Jane 8/5/2010

Hi,
here is a sample code how to move file:

http://xlinesoft.com/phprunner/docs/upload_files_to_users_folders.htm
$files_move array is procesed in the generated include/phpfunctions.php file in the ProcessFiles() function. You can copy and modify code from this function in your event.

A
aptivus author 8/5/2010



Hi,
here is a sample code how to move file:

http://xlinesoft.com/phprunner/docs/upload_files_to_users_folders.htm
$files_move array is procesed in the generated include/phpfunctions.php file in the ProcessFiles() function. You can copy and modify code from this function in your event.


Thanks again Jane, but it seems it doesn't work or myabe I'm getting something wrong.

Here is the whole code of the function:

global $files_move;
foreach( $files_move as $key=>$val)

{

if($val[0]==$_FILES["file_url_picture"]["tmp_name"])
$files_move[$key][1] = "files/".$values["url_picture"];

}
$bacheca_query = "CALL BAC_CREATE_ADM_MESSAGE('IT','".$values['Titolo']."','".$values['Estratto']."',

'".mysql_real_escape_string($values['Contenuto'])."','".$values['url_picture']."','".$values['category']."',@titolo,@abstract,@testo,@id_messaggio)";
$inserisci_bacheca = mysql_query($bacheca_query);
$bacheca_en_queryT = "CALL TXT_SET_MESSAGE(@titolo,'".$values['TitoloEN']."','EN')";

$inserisci_bacheca_ingleseT = mysql_query($bacheca_en_queryT);
$bacheca_en_queryE = "CALL TXT_SET_MESSAGE(@abstract,'".$values['EstrattoEN']."','EN')";

$inserisci_bacheca_ingleseE = mysql_query($bacheca_en_queryE);
$bacheca_en_queryC = "CALL TXT_SET_MESSAGE(@testo,'".$values['ContenutoEN']."','EN')";

$inserisci_bacheca_ingleseC = mysql_query($bacheca_en_queryC);
if(($inserisci_bacheca)&&($inserisci_bacheca_ingleseT)&&($inserisci_bacheca_ingleseE)&&($inserisci_bacheca_ingleseC))
$message = "<div style='width:100%; padding: 15px; border:1px solid green; background-color:#d5f4df;text-align:center;'>RECORD INSERITO CORRETTAMENTE</div>";

return false;


What's wrong with it?

A
aptivus author 8/6/2010

Sorry Jane,

I just forgot a bit of code in my function.

It works properly now.

I just added

global $files_move;
foreach( $files_move as $key=>$val)
{
if($val[0]==$_FILES["file_url_picture"]["tmp_name"])
$files_move[$key][1] = "files/".$values["url_picture"];

move_uploaded_file($val[0],$files_move[$key][1]);
}


Thanks for your precious help