fantomel Posted April 5, 2009 Share Posted April 5, 2009 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 More sharing options...
Yesideez Posted April 5, 2009 Share Posted April 5, 2009 You can continue to access the $_FILES variable throughout your script directly. Link to comment https://forums.phpfreaks.com/topic/152632-solved-hello-advice-needed/#findComment-801573 Share on other sites More sharing options...
fantomel Posted April 5, 2009 Author Share Posted April 5, 2009 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 Link to comment https://forums.phpfreaks.com/topic/152632-solved-hello-advice-needed/#findComment-801583 Share on other sites More sharing options...
Yesideez Posted April 5, 2009 Share Posted April 5, 2009 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]); Link to comment https://forums.phpfreaks.com/topic/152632-solved-hello-advice-needed/#findComment-801586 Share on other sites More sharing options...
techcone Posted April 5, 2009 Share Posted April 5, 2009 Why not make a seperate file, declare variables there and include it in main file. Link to comment https://forums.phpfreaks.com/topic/152632-solved-hello-advice-needed/#findComment-801621 Share on other sites More sharing options...
fantomel Posted April 5, 2009 Author Share Posted April 5, 2009 i was thinking more on using foreach :-? but i'm not sure... Link to comment https://forums.phpfreaks.com/topic/152632-solved-hello-advice-needed/#findComment-801677 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.