Visualizzazione dei risultati da 1 a 2 su 2

Discussione: set_time_limit

  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2006
    Messaggi
    656

    set_time_limit

    allora ragazzi,

    io devo far caricare grossi file sul server, finoa 50MB.

    ovviamente lo script va in timeout. qui trovate le phpinfo del mio server.

    girando ho trovato la funzione set_time_limit.


    ora, puo funzionare per le mie esigenze? come la implemento in questo script?

    Codice PHP:
    <?

    $extlimit 
    "no"//Do you want to limit the extensions of files uploaded
    $limitedext = array(".gif",".jpg",".png",".jpeg"); //Extensions you want files uploaded limited to.
    $sizelimit "no"//Do you want a size limit, yes or no?
    $sizebytes "10000000"//size limit in bytes
    $dl "http://www.xxx.com/upload/upload"//url where files are uploaded
    $absolute_path "/web/htdocs/xxxx/home/upload/upload"//Absolute path to where files are uploaded
    $websiteurl "http://www.cxxxx.com"//Url to you website
    $websitename "Zach White Network";

    if (!isset(
    $action)) {
        
    $action "";
    }

    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>[url="
    $PHP_SELF?action=upload>Upload"] <a href=$websiteurl>Return to $websitename[/url]";
    $list "<table width=700 border=1 bordercolor=#000000 style=\"border-collapse: collapse\">";
    $list .= "<tr><td width=700><center>[b]Click To Download[/b]</center></td></tr>";
    $dir opendir($absolute_path);
    while(
    $file readdir($dir)) {
    if ((
    $file != "..") and ($file != ".")) {
    //Download files with spaces fix by Kokesh
    $list .= "<tr><td width=700>[url='$dl/$file']$file[/url]</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.");
    }

    $ext strrchr($file_name,'.');
    if ((
    $extlimit == "yes") && (!in_array($ext,$limitedext))) {
    die(
    "The file you are uploading doesn't have the correct extension.");
    }

    @
    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;

    }
    ?>

  2. #2
    Inserisci nello script:

    Codice PHP:
    <?php
    $timeout 
    300// 5 minuti di timeout
    set_time_limit($timeout);

    ?>
    Reference: http://it.php.net/function.set-time-limit
    Emanuele DG
    <?php echo "Proverbio zen(d): vivi ogni giorno come se fosse il ".date('d M Y', time()); ?>
    Intellectual property

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.