Jump to content


Passing a file to a funcion with user input

  • Please log in to reply
1 reply to this topic

#1 Andy-T

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 20 May 2006 - 03:12 PM


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">

I tried adding value="YourFile.txt" 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
} //EndOfFunction

I'm new to any real kind of web programing so any help will be appreacated.


#2 Andy-T

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 20 May 2006 - 05:24 PM

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.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users