Upload Script

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Upload Script

    Ich habe mit Google folgendes Script gefunden:

    Uploader.php
    PHP-Code:
    <HTML>
    <HEAD>
      <TITLE>Uploader v1.1</TITLE>
    </HEAD>
    <BODY BGCOLOR="#ffffff">
    <!--

    Powered by: Uploader Version 1.1 

    -->
    <?php
    require("setup.php");

    if(
    $doupload) {

    if(
    $ADMIN[RequirePass] == "Yes") {
    if(
    $password != "$ADMIN[Password]") {
    ?>
    <P><CENTER><B><FONT FACE="Verdana">Error</FONT></B></CENTER></P>
    <P><CENTER><TABLE WIDTH="450" BORDER="0" CELLSPACING="0"
    CELLPADDING="0">
      <TR>
        <TD WIDTH="100%" BGCOLOR="#000000">
        <TABLE WIDTH="450" BORDER="0" CELLSPACING="1" CELLPADDING="2">
          <TR>
            <TD COLSPAN="2" BGCOLOR="#ffffff">
            <FONT COLOR="#000000" SIZE="-1" FACE="Verdana">Invalid Password</FONT></TD>
          </TR>
        </TABLE></TD>
      </TR>
    </TABLE></CENTER></P>
    <P><CENTER>&nbsp;</CENTER></P>
    <P><CENTER>&nbsp;</CENTER></P>
    </BODY>
    </HTML>
    <?php
    exit();
    }
    }

    $num 0;
    while(
    $num $ADMIN[UploadNum]) {
    $num++;


    $picture "fileup$num"."_name";
    $picture1 = $$picture;
    $picture2 "fileup$num";
    $picture3 = $$picture2;

    if(
    $picture3 != "none") {
    $filesizebtyes filesize($picture3);

    $ok 1;
    if(
    $filesizebtyes 10) {
    $error .= "Error uploading (file size lower than 10 bytes) for file $num<BR>";
    $ok 2;
    }



    if(
    file_exists("$ADMIN[directory]/$picture1") OR $ok == 2) {
    $error .="File name already exists for file $num<BR>";
    } else {
    copy ($picture3"$ADMIN[directory]/$picture1");
    $error .="File $num has been uploaded<BR>";
    }
    }
    }

    if(!
    $error) {
    $error .= "No files have been selected for upload";
    }


    ?>
    <P><CENTER><B><FONT FACE="Verdana">Status</FONT></B></CENTER></P>

    <P><CENTER><TABLE WIDTH="450" BORDER="0" CELLSPACING="0"
    CELLPADDING="0">
      <TR>
        <TD WIDTH="100%" BGCOLOR="#000000">
        <TABLE WIDTH="450" BORDER="0" CELLSPACING="1" CELLPADDING="2">
          <TR>
            <TD COLSPAN="2" BGCOLOR="#ffffff">
            <FONT COLOR="#000000" SIZE="-1" FACE="Verdana"><?php echo $error?></FONT></TD>
          </TR>
        </TABLE></TD>
      </TR>
    </TABLE></CENTER></P>
    <P><CENTER>&nbsp;</CENTER></P>
    <P><CENTER>&nbsp;</CENTER></P>
    </BODY>
    </HTML>
    <?php
    exit();

    } else {

    $num 0;
    while(
    $num $ADMIN[UploadNum]) {
    $num++;
    $html .= "<TR>
            <TD WIDTH=\"25%\" BGCOLOR=\"#295e85\">
            <FONT COLOR=\"#ffffff\" SIZE=\"-1\" FACE=\"Verdana\">File 
    $num:</FONT></TD> 
            <TD WIDTH=\"75%\" BGCOLOR=\"#ffffff\">
            <INPUT NAME=\"fileup
    $num\" TYPE=\"file\" SIZE=\"25\">
    </TD> "
    ;
    }

    ?>
    <FORM ENCTYPE="multipart/form-data" ACTION="uploader.php" METHOD="POST">
    <P><CENTER><B><FONT FACE="Verdana">Upload</FONT></B></CENTER></P>

    <P><CENTER><TABLE WIDTH="450" BORDER="0" CELLSPACING="0" CELLPADDING="0">
      <TR>
        <TD WIDTH="100%" BGCOLOR="#000000">
        <TABLE WIDTH="450" BORDER="0" CELLSPACING="1" CELLPADDING="2">
          <TR>
            <TD COLSPAN="2" BGCOLOR="#295e85">
            <B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Select Files</FONT></B></TD>
             
          </TR><?php echo $html?>
        </TABLE></TD>
      </TR>
    </TABLE></CENTER></P>
    <?php
    if($ADMIN[RequirePass] == "Yes") {
    ?>
    <P><CENTER><TABLE BORDER="0" CELLSPACING="0"  CELLPADDING="0">
      <TR>
        <TD WIDTH="100%" BGCOLOR="#000000">
        <TABLE WIDTH="300" BORDER="0" CELLSPACING="1" CELLPADDING="2">
          <TR>
            <TD WIDTH="33%" BGCOLOR="#295e85">
            <B><FONT COLOR="#ffffff" SIZE="-1" FACE="Verdana">Password:</FONT></B></TD> 
            <TD WIDTH="67%" BGCOLOR="#ffffff">
            <INPUT NAME="password" TYPE="password" SIZE="25">
    </TD> 
          </TR>
        </TABLE></TD>
      </TR>
    </TABLE></CENTER></P>
    <?php
    }
    ?>
    <P><CENTER><INPUT NAME="doupload" TYPE="submit" VALUE="Upload Files"></CENTER></FORM>
    <P><CENTER>&nbsp;</CENTER></P>
    <P><CENTER>&nbsp;</CENTER></P>
    </BODY>
    </HTML>
    <?php
    exit();
    }


    ?>
    setup.php

    PHP-Code:
    <?php

    // (c) Copyright 2001 PHP Script CENTER

    $ADMIN[RequirePass] = "No";   // Checks to see if upload has a vaild password
    $ADMIN[Password] = "password";   // This is the password if the above option is Yes
    $ADMIN[UploadNum] = "5";  // Number of upload feilds to put on the html page
    $ADMIN[directory] = "uploads";  // The directory the files will
    //be uploaded to (must be chmoded to 777)

    ?>
    In der setup.php werden gewisse Eigenschaften wie passwort, upload verzeichnis und anzahl der felder definiert.

    Ich möchte jetzt erreichen, dass Dateien mit demselben Dateinamen überschrieben werden.
    Bisher ist es so, dass dann eine Fehlermeldung ausgegeben wird.

    Ich hoffe das ist zu realisieren

    Für Hilfe bedanke ich mich im Vorraus

    MfG
    Marius
    Zuletzt geändert von MariusP; 13.03.2004, 14:40.

  • #2
    Änder das
    PHP-Code:
    if(file_exists("$ADMIN[directory]/$picture1") OR $ok == 2) {
    $error .="File name already exists for file $num<BR>";
    } else {
    copy ($picture3"$ADMIN[directory]/$picture1");
    $error .="File $num has been uploaded<BR>";
    }
    }

    mal in das

    PHP-Code:
    copy ($picture3"$ADMIN[directory]/$picture1");
    $error .="File $num has been uploaded<BR>";
    }

    Kommentar


    • #3
      Vielen Dank, dass klappt wunderbar.
      Zur Zeit ist da nur eine Sperre für Dateien kleiner als 10 Bytes. Wie könnte man jetzt noch eine maximale Dateigröße angeben. z.B. das Dateien größer als 250kb ebenfalls mit einer entsprechenden Fehlermeldung geblockt werden.

      Für Hilfe bedanke ich mich im Vorraus

      MfG
      Marius

      Kommentar


      • #4
        hmm, ein bisschen Grundlagen solltest du schon beherrschen.

        such dir einfach die stelle, wo das minimum abgefragt wird, kopiere das und änder das in ein maximum.

        Kommentar

        Lädt...
        X