Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Upload PHP

  1. #1

    Upload PHP

    Ciao, ho un serio problema ke nn riesco a risolvere:
    sono iscritto su altervista e sbirciando tra le risorse ho trovato questo codice:
    [inizio codice]
    <?
    $sizelimit = "no"; //Do you want a size limit, yes or no?
    $sizebytes = "200000"; //size limit in bytes
    $dl = "http://www.zachwhite.com/demo/up-down"; //url where files are uploaded
    $absolute_path = "/home/zachwhit/public_html/demo/up-down"; //Absolute path to where files are uploaded
    $websiteurl = "http://www.zachwhite.com"; //Url to you website
    $websitename = "Zach White Network";

    switch($action) {
    default:
    echo"
    <html>
    <head>
    <title>Upload Or Download</title>
    </head>
    <body>
    <a href=$PHP_SELF?action=upload>Upload File</a>
    <a href=$PHP_SELF?action=download>Download File</a>
    <a href=$websiteurl>Return to $websitename</a>



    Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
    </body>
    </html>";
    break;
    case "download":
    echo "
    <html>
    <head>
    <title>File Download</title>
    </head>
    <body> <a href=$websiteurl>Return to $websitename";
    $list = "<table width=700 border=1 bordercolor=#000000 style=\"border-collapse: collapse\">";
    $list .= "<tr><td width=700><center>Click To Download</center></td></tr>";
    $dir = opendir($absolute_path);
    while($file = readdir($dir)) {
    if (($file != "..") and ($file != ".")) {
    $list .= "<tr><td width=700><center><a href=$dl/$file>$file</a></center></td></tr>";
    }
    }
    $list .= "</table>";
    echo $list;
    echo"



    Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
    </body>
    </html>";
    break;

    case "upload":
    echo"
    <html>

    <head>
    <title>File Upload</title>
    </head>

    <body>

    <form method=POST action=$PHP_SELF?action=doupload enctype=multipart/form-data>


    File to upload:

    <input type=file name=file size=30>


    <button name=submit type=submit>
    Upload
    </button>
    </form>



    Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
    </body>

    </html>";
    break;


    //File Upload
    case "doupload":
    $dir = "dir";
    if ($file != "") {

    if (file_exists("$absolute_path/$file_name")) {
    die("File already exists");
    }

    if (($sizelimit == "yes") && ($file_size > $sizebytes)) {
    die("File is to big. It must be $sizebytes bytes or less.");
    }


    @copy($file, "$absolute_path/$file_name") or die("The file you are trying to upload couldn't be copied to the server");

    } else {
    die("Must select file to upload");
    }
    echo "
    <html>
    <head>
    <title>File Uploaded</title>
    </head>
    <body>";
    echo $file_name." was uploaded";
    echo "

    <a href=$PHP_SELF?action=upload>Upload Another File</a>
    <a href=$PHP_SELF?action=download> Download File</a>
    <a href=$websiteurl> Return to $websitename</a>


    Powered by <a href=http://www.zachwhite.com/>PHP Uploader Downloader</a>
    </body>
    </html>";
    break;

    }
    ?>
    [fine codice]
    interessante script non è vero?
    il problema è ke sul mio sito nn m fa uplodare...perchè? non capisco... ma più esattamente cs devo mettere in $dl, $absolute_path e $websiteurl?
    vi prego aiutatemi!

  2. #2
    Possibili problemi con l'upload:
    1. Non hai i diritti di scrittura nella data cartella dove vuoi effettuare l'upload?
    2.
    $dl = "http://www.zachwhite.com/demo/up-down";
    //url where files are uploaded
    $absolute_path = "/home/zachwhit/public_html/demo/updown";
    //Absolute path to where files are uploaded
    $websiteurl = "http://www.zachwhite.com";
    //Url to you website

    Che problema hanno queste var? così ad occhium e croce nessuno
    $dl =l'indirizzo URL della cartella dove i file verranno uploaddati
    $absolute_path = la path assolutata di tale cartella
    (fai un php_info(); in una pagina qualsivoglia e troverai tra i vari dati qual'è la tua path assoluta)
    $websiteurl= l'indirizzo del tuo sito web?

    I will use Google before asking dumb questions.
    http://www.weiterbildungsblog.de/archives/google.jpg

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2003
    Messaggi
    191
    se hai altervista la absolute path è /membri/TUONOME

    codice:
    $sizelimit = "no"; //Do you want a size limit, yes or no?
    $sizebytes = "200000"; //size limit in bytes
    $dl = "http://TUONOME.altervista.org/CARTELLADOVEVETTIIFILEUPPATI"; //url where files are uploaded
    $absolute_path = "/membri/TUONOME/CARTELLADOVEVETTIIFILEUPPATI/"; //Absolute path to where files are uploaded
    $websiteurl = "http://TUONOME.altervista.org"; //Url to you website
    $websitename = "QUEllo che preferisci";
    edit
    aggiungo che io sto usando da qualche settimana questo script ma ha un bug :se i nomi dei file contengono spazi nn puoi fare il download

  4. #4
    aggiungo che io sto usando da qualche settimana questo script ma ha un bug :se i nomi dei file contengono spazi nn puoi fare il download
    Per ovviare a questo problema forse vi è utile la funzione urlencode(), che trasforma gli spazi in %20 così da non dare problemi

    I will use Google before asking dumb questions.
    http://www.weiterbildungsblog.de/archives/google.jpg

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.