Jump to content

[SOLVED] Hello Advice needed.


fantomel

Recommended Posts

Hello i'm having some vars for a an upload form

 


                $file_name1       = $_FILES['userfile']['name'][1];
	$tmp_file_name  = $_FILES['userfile']['tmp_name'][1];
	$file_type          = $_FILES['userfile']['type'][1];
	$file_size           = $_FILES['userfile']['tmp_name'][1];
	$error_file          = $_FILES['userfile']['error'][1];

 

Can you please give me an advice a method how i could do this in other way without defining so many vars?

Link to comment
https://forums.phpfreaks.com/topic/152632-solved-hello-advice-needed/
Share on other sites

Yes i know i could do that but when i would like to do changes i will have to look over the code to search for that var and what it does so it's not a solution

the form i'm doing it has a total of 40 variables 5 upload fields and the rest is for the text.. that's why i'm searching for an option i don't want so many vars in my script and maybe in time i would like to refactor it as php class

What about setting up an array?

$arrUserfile=array('name'=>$_FILES['userfile']['name'][1],
    'tmp'=>$_FILES['userfile']['tmp_name'][1],
    'type'=>$_FILES['userfile']['type'][1],
    'size'=>$_FILES['userfile']['size'][1],
    'error'=>$_FILES['userfile']['error'][1]);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.