1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

UPload Image or video in server size more then 40 MB

Discussion in 'PHP' started by ksamir2004, May 29, 2008.

  1. #1
    Hi All,

    Can any on ehelp me out to upload video or Image file in server without change of php.ini file..

    file size should be more then 40 MB..

    Thanks
    Sam
     
    ksamir2004, May 29, 2008 IP
  2. roy.laurie

    roy.laurie Peon

    Messages:
    51
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You'll need a Java or Flash app on the client side to break the client's file up into chunks. Then just use PHP to save the chunks and combine them when the download has completed.
     
    roy.laurie, May 29, 2008 IP
  3. ksamir2004

    ksamir2004 Peon

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi Roy,

    Can you give me some idea...
     
    ksamir2004, May 29, 2008 IP
  4. roy.laurie

    roy.laurie Peon

    Messages:
    51
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well, your PHP script would pass the maximum size allowed to the Java / Flash app.

    Then the client-side code would:
    - open the file
    - break it up into chunks of X bytes (determined by the max sized passed to it)
    - send the total number of pieces calculated using "ajax"
    - send each piece as a separate file with an "ajax" request (myfile.mpeg.part01, myfile.mpeg.part02)

    The PHP client would save each file to a temporary folder. When it finishes receiving the last part, it'd use file operations to open and append each piece to a new file which will become the main file.

    See?
     
    roy.laurie, May 29, 2008 IP
  5. Sevby

    Sevby Guest

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Here's three ways you can do this. Don't choose more than one way.

    • Insert the following code into your script.
      ini_set('upload_max_filesize', '100M');
      ini_set('post_max_size', '100M');
      PHP:
      1. Create a file called php.ini in the same directory your script is in.
      2. Insert the following code into the file.
        upload_max_filesize = 100M
        post_max_size = 100M
        Code (markup):
      1. Create a file called .htaccess in the same directory your script is in.
      2. Insert the following code into the file.
        php_value upload_max_filesize 100M
        php_value post_max_size 100M
        Code (markup):
     
    Sevby, May 30, 2008 IP
  6. designcode

    designcode Well-Known Member

    Messages:
    738
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    118
    #6
    If you're good at programming, I'd recommend you the roy.laurie's method.
     
    designcode, May 30, 2008 IP
  7. Sevby

    Sevby Guest

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    He just wants a simple way to change the upload limit, not to learn Java/Flash and create a whole new upload client in another language: all that just to achieve a simple thing? I'd rather ask my host to change the limit, move to another host or use my method instead of learning a whole new language and making a whole new program just to achieve a simple thing. All you need to do is take five seconds of your time to copy and paste two lines of code.
     
    Sevby, May 30, 2008 IP
  8. ksamir2004

    ksamir2004 Peon

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi Sevby,

    i am using this code.. throught this code i can upload any Doc, txt, pdf, file..

    can you help me to upload video, mp3 file.

    Thanks..
    <?php
    if($x!=' ')
    {
    $target = "C:/Program Files/Apache/Apache2.2/htdocs/xx/";
    $target = $target . basename( $_FILES['uploaded']['name']) ;
    $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
    {echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
    $string = split("/",$target);
    $x=$string[6]; // $x will show you file name.
    } else{
    echo "There was an error uploading the file, please try again!";
    }
    }
     
    ksamir2004, May 30, 2008 IP
  9. Sevby

    Sevby Guest

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Have you tried any of the methods I have posted?
     
    Sevby, May 30, 2008 IP
  10. ksamir2004

    ksamir2004 Peon

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    No i didn't tried. even i am bit confused? can you help me out..

    Thanks,
     
    ksamir2004, May 30, 2008 IP
  11. Sevby

    Sevby Guest

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Try some of my methods then...
     
    Sevby, May 30, 2008 IP
  12. roy.laurie

    roy.laurie Peon

    Messages:
    51
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Well I assumed he had tried the ini configs first as he said that he couldn't touch php.ini.

    Either way, though, I probably wouldn't use that method for the sizes larger than 40MB.
    1. Users are impatient and will close the browser or cancel it somehow.
    2. There's a chance of it timing out on many web servers.

    Vanilla HTTP is horrible for file uploads. I wouldn't rely on it for anything large. If you're looking for a fast solution rather than a snazzy one, I would consider using an anonymous FTP account with a Java-based FTP client embedded into your site
     
    roy.laurie, May 30, 2008 IP