Andy-T Posted May 20, 2006 Share Posted May 20, 2006 Hi,Maybe someone would be good enough to give me a helping hand.I just need a button that passes a static file name to a fuction, there's probably more to it than I know. I can do it through uploading the file but I don't want users to be able to choose the file, just hit the button to make it happen :-).Here's the form that lets me upload and call the fuction.<form enctype= "multipart/form-data" name="form1" method="post" action="<?php echo $PHP_SELF; ?>"><input name="textfile" type="file" value="YourFile.txt" class="arial12" style="width: 305px; border : 1px solid black;" ><input type="submit" name="importtextfilesubmit" value="Import" width="80"></form>I tried adding [b]value="YourFile.txt"[/b] but this did'nt help :-(. Here's the fuction I need to pass to.function importcommaseparateddata($textfile, $textfile_name, &$status, &$newusers, $existingusers) { global $languagearray; if($textfile=="none" OR $textfile=="") { //No file selected $status .= $languagearray[15]; } else { /* File was selected correctly */ if(move_uploaded_file ($textfile, "./".$textfile_name)==true) { /* Upload okay */ createhtaccess($status); /* .htaccess anlegen */ $textfilehandle = fopen ($textfile_name, "r"); /* open transferred textfile */ while ($data = fgetcsv ($textfilehandle, 1000, ",")) { /* read and parse commaseparated data */ $newuser = $data[0]; $newpass = $data[1]; if (checkimports($newuser, $newpass, $status, $existingusers) == true) { /* Importierte Daten prüfen */ adduser($newuser, $newpass, $status, $newusers); /* Userinfo in $newusers ablegen */ } //endif } //endwhile createhtpasswd($newusers, $status, $existingusers); /* user in .htpasswd eintragen */ fclose ($textfilehandle); if(unlink($textfile_name)==false ) { $status .= $languagearray[19].$textfile_name.$languagearray[20]; } //endif } else { $status .= $languagearray[18]; } //endif } //endif} //EndOfFunctionI'm new to any real kind of web programing so any help will be appreacated.Andy-T Link to comment https://forums.phpfreaks.com/topic/10067-passing-a-file-to-a-funcion-with-user-input/ Share on other sites More sharing options...
Andy-T Posted May 20, 2006 Author Share Posted May 20, 2006 I don't think I have a chance from what I've found out so far. All I need is a button that passes the file to the function. The file is already on my web server.CheersAndy Link to comment https://forums.phpfreaks.com/topic/10067-passing-a-file-to-a-funcion-with-user-input/#findComment-37457 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.