SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    SitePoint Zealot Harvy's Avatar
    Join Date
    Feb 2002
    Location
    Aberdeen, Scotland
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    File upload timeout?

    Hi there iv been working on a File upload system for my webby but it appears to be timeing out to quickly, this upload system is for Screen Shots from Counter Strike so they are rather large files real need it so there is no timelimit.

    heres my script so far thx.
    PHP Code:
    <?php


        
    if ($uploadedfile_type == "image/pjpeg"
            
    or $uploadedfile_type == "image/gif") {
         
    //Handle the file...
        
    }else{
         echo (
    "<p>Please submit a JPEG or GIF image " 
        
    "file.</p>\n");
         exit();
        }
        
    // Pick a file extension
        
    if ( "image/pjpeg" == $uploadedfile_type $extension ".jpg";
        else 
    $extension ".gif";
        
        
    // The complete path/filename
        
    $filename "/usr/local/psa/home/vhosts/tomowebsite.com/httpdocs/fc3/uploads/" time() . $REMOTE_HOST $extension;
        
        
    // Copy the file (if it is deemed safe)
        
    if (move_uploaded_file($uploadedfile$filename)) {
        echo(
    "<p>File stored successfully as $filename.</p>");
        }else{
        echo (
    "<p>Could not save file as $filename!</p>");
        exit();
        }

        
    $photo ereg_replace("^/usr/local/psa/home/vhosts/tomowebsite.com/httpdocs","",$filename);

        
    $dbcnx mysql_connect("""""");
        if (!
    dbcnx) {
            echo (
    "<p>Unable to connect to database server at this time!</p>");
            exit();
            }
         
    mysql_select_db("Virtual",$dbcnx);
         if (! @
    mysql_select_db("Virtual") ) {
             echo (
    "Unable to locate the Virtual database at this time.</p>");
            exit();
            }
         
          
    $sql "INSERT INTO `screengrabs` (`photo`) VALUES ('$photo')";
            if (@
    mysql_query($sql)) {
                echo(
    "<p>$photo successfully placed in database.</p>");
                }else{
                echo(
    "<p>Error adding $photo to database!</p>");
                }
        echo 
    "<img src=$filename>";
    ?>

  2. #2
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to avoid timeouts, you need to edit your php.ini max_execution_time to something reasonable (standard is 30 second)...e.g.:
    Code:
    max_execution_time = 90     ; Maximum execution time of each script, in seconds (UNIX only)
    and, while you're there, it's worth making sure you can upload large enough files, like say 2 MB
    Code:
    upload_max_filesize = 2097152       ; 2 Meg default limit on file uploads
    hope this helps...
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  3. #3
    SitePoint Zealot Harvy's Avatar
    Join Date
    Feb 2002
    Location
    Aberdeen, Scotland
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would i go about editing my php.ini file ??

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how big of a file are you trying to upload? there has been a discussion about uploading large files here: http://www.sitepointforums.com/showt...threadid=50669

    we found, at least in the latest version of PHP, that max_execution_time and memory_limit don't affect anything. just make sure post_max_size and upload_max_filesize are bigger than the file you are trying to upload.

    BTW, php.ini should be in your Windows or WINNT directory or on *nix, /usr/local/lib/php.ini or /etc/php.ini.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  5. #5
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry if my reply was confusing...should have specified it worked for me under PHP 4.1.2 and that your mileage may vary...
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  6. #6
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you will also need to check out what limits your server currently has (after spending hours trying to figure out why changing the php.ini file didn't work I realised my server was set to a 1mb limit )

    sarah
    Regular user

  7. #7
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you mean apache ?
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  8. #8
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    actually (sambar server but I suppose other server will also have the same thing? or not don't know :
    Regular user

  9. #9
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by DR_LaRRY_PEpPeR
    we found, at least in the latest version of PHP, that max_execution_time and memory_limit don't affect anything. just make sure post_max_size and upload_max_filesize are bigger than the file you are trying to upload.
    forget that. i installed 4.2.0 last night and max_execution_time is now a problem. see the thread i posted above for more info.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •