Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    141
    Thanks
    3
    Thanked 1 Time in 1 Post

    execuation time for uploading files?

    hello guys .

    i wonder what is the best way that you guys would do for a script that does upload the file and a script that can view uploaded file and click the link and download it .

    i am trying to upload the file into database as BLOB type and i am able to do it only for small size files. i can not upload for like 2-5MB (typical an mp3 file )

    my code is like this

    PHP Code:
    <?php
    require_once("../includes/application.php");
    if(isset(
    $_POST['upload']) && $_FILES['userfile']['size'] > 0)
    {
        
    $fileName = (isset($_FILES['userfile']['name'])) ? $_FILES['userfile']['name'] : '';
        
    $tmpName = (isset($_FILES['userfile']['tmp_name'])) ? $_FILES['userfile']['tmp_name'] : '';
        
    $fileSize = (isset($_FILES['userfile']['size'])) ? $_FILES['userfile']['size'] : '';
        
    $fileType = (isset($_FILES['userfile']['type'])) ? $_FILES['userfile']['type'] : '';
        
    $fileError = (isset($_FILES['userfile']['error'])) ? $_FILES['userfile']['error'] : '';
        
        if (
    $fileError 0)
            echo 
    "errorerrorerror";
        
        
    $fp      fopen($tmpName'r');
        
    $content fread($fpfilesize($tmpName));
        
    $content addslashes($content);
        
    fclose($fp);

        
    $connection = new DBManager;
        
    $connection->getConnection();
        
        if(!
    get_magic_quotes_gpc())
        {
            
    $fileName addslashes($fileName);
        }



    $query "INSERT INTO upload (name, size, type, content ) ".
    "VALUES ('$fileName', '$fileSize', '$fileType', '$content')";

        if (
    $connection->query($query)){
        echo 
    "<br/>File $fileName uploaded <br/>";
        } else {
        echo 
    "$fileName is NOT uploaded";
        }
    }

    ?>


    <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'?>">
        <table width="350" border="0" cellpadding="1" cellspacing="1">
            <tr>
                <td width="246">
                    <input type="hidden" name="MAX_FILE_SIZE" value="40960">
                    <input name="userfile" type="file" id="userfile">
                </td>
            </tr>
        </table>
        <input name="upload" type="submit" id="upload" value="Upload">
    </form>
    it wont let me upload file like i guess more that 2MB ( or even more than 1MB )

    is there any config in php.ini ( well there is but the max file upload by default is 16M if I am not mistaken ) ....

    or Can't I not upload a song file into Database ?

    how do you guys normally do for kinda like file manager where one side can upload and one side can download it ?

    thanks in advance

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Are you getting any error while uploading? Does your network have enough speed to transfer the file before the max_execution time (set in your ini file)?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Apr 2007
    Posts
    141
    Thanks
    3
    Thanked 1 Time in 1 Post
    i dont get any error and the script just does not execute properly i think . then it gets back to orginial as if nothing happened.

    no i am trying this upload / download in localhost . there should n't be netwrk issue .

    btw .on this one i upload data into database.

    i actually wanted to upload data into a directory in web server then we are able to sort of manipulate the data such as sorting them by the day those data are uploaded.... or by how big is the size of the data.

    if i want to do that, i would have to use database right ? is there any way that i dont store the data into database but on the "download page" people could find the data (in ordered fashion such as by time uploaded / size of the data )and then they can download it based on the link that they have.

    thanks


  •  

    Posting Permissions

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