phpbar.de logo

Mailinglisten-Archive

Re: [php] Uploadmoeglichkeit von Grafiken
Archiv Mailingliste php_(at)_infosoc.uni-koeln.de

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [php] Uploadmoeglichkeit von Grafiken



"Hoeschl, Peter" wrote:
> Kann mir jemand einen entsprechenden Source zur Verfügung stellen, da
> ich noch nicht so sattelfest in PHP bin?
> Oder zumindest ein paar Anstoesse geben, in welche Richtung meine Reise
> geht?

Meine Antwort zu entsprechender Anfrage in php3:

Rene Paschold wrote:
> <FORM ENCTYPE="multipart/form-data" ACTION="test.php3" METHOD=POST>
> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000">
> Send this file: <INPUT NAME="userfile" TYPE="file">
> <INPUT TYPE="submit" VALUE="Send File">
> </FORM>

phph3 does magic and copies the file for you. You need to copy this
file to a safe location. Here's how I do it (learnt from Ralf
Geschke, thanks to him!):

In your test.php3, you write something like:

   proc_upload($Email,$userfile,$userfile_name,$userfile_size);

I include the email address, as I allow for no or multiple file
upload. Here is my function:

   function proc_upload(
        $Email,
        $userfile,
        $userfile_name,
        $userfile_size)
   {
      $completedir = "/www/pferdezeitung/anonftp/incoming/";
      if ($userfile_name == ""){exit;}
      if (chop($userfile_name) == "")
            {
                mail("ads_(at)_pferdezeitung.com", 
                "no filename", 
                "wasn't that good", 
                "From: $Email");
                return 0;
            }
      if ($userfile_size > 0)
        {
          if (!copy($userfile,
                $completedir . 
                $Email . "-" .
                $userfile_name))
            {
                mail("ads_(at)_pferdezeitung.com", 
                "no copy", 
                "$userfile_name # userfile_name", 
                "From: $Email");
                print "Warning: No copy!<br>\n";
                return 0;
            }
        else {
                mail("ads_(at)_pferdezeitung.com", 
                     "$Email . "has sent " . $userfile_name", 
                     "File uploaded, 
                     size is $userfile_size", 
                     "From: $Email");
              }
        }
                return 1;
   }


-- 
Mit freundlichem Gruss
Werner Stuerenburg

_____________________________________________________________
ISIS  Gesellschaft fuer Softwareentwicklung und -vertrieb mbH
Webdesign - Uhlandstr. 8  -  D-32120 Hiddenhausen  -  Germany
Tel. 0(049)5224-9974-07, Fax-09,  <mailto:ws_(at)_art-quarter.com>
-  <http://art-quarter.com>  -  <http://pferdezeitung.com>  -


Home | Main Index | Thread Index

php::bar PHP Wiki   -   Listenarchive