unlimited uploading in php

Discussion in 'PHP' started by flawlessking, Dec 24, 2008.

  1. #1
    Hello guys m very new to the php world and m in the learning process...
    i got the uploading script frm w3schools...but it has got some limits
    1.i want unlimited uploading script for my web page where user can upload there stuff with no file size limit......


    2.and also when i upload stuff it directly goes into the folder called UPLOADS [as scripted] but i want the file which i upload should display in new html page where it will be visible for download after uploading....so please give me the scripts i'l be very grateful
     
    flawlessking, Dec 24, 2008 IP
  2. planemaniac

    planemaniac Peon

    Messages:
    49
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think I see what you want to do now. I'm not sure if this will work, as I can't test it right now, so just try and see.

    Change the opening of the script to this:

    
    <?php
    
    if ((($_FILES["file"]["type"] == "image/gif")
    || ($_FILES["file"]["type"] == "image/jpeg")
    || ($_FILES["file"]["type"] == "image/pjpeg"))
    && ($_FILES["file"]["size"] > 0)) // Instead of making sure the file is less than 20,000 bytes, it now makes sure it is more than 0, so unlimited size basically
      {
    
    PHP:
    For your next thing, where you want the script to add a link to a HTML page for downloading, you could add something like this:

    
    
    $file = fopen("downloads.html", "a") or exit ("Can't open downloads.html for editing");
    
    $to_add = "<a href=\"uploads/$name_of_upload_file\">$name_of_upload_file</a><br />";
    
    fwrite($file, $to_add);
    fclose($file);
    
    PHP:
    That's along the lines of what you need to do.

    Hope that helps
     
    planemaniac, Dec 24, 2008 IP
  3. flawlessking

    flawlessking Well-Known Member

    Messages:
    136
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    well let me try...
     
    flawlessking, Dec 24, 2008 IP
  4. flawlessking

    flawlessking Well-Known Member

    Messages:
    136
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #4
    """1.well i did this but nothing is getting uploaded above 2mb"""""

    <?php

    if ((($_FILES["file"]["type"] == "image/gif")
    || ($_FILES["file"]["type"] == "image/jpeg")
    || ($_FILES["file"]["type"] == "image/pjpeg"))
    && ($_FILES["file"]["size"] > 0)) // Instead of making sure the file is less than 20,000 bytes, it now makes sure it is more than 0, so unlimited size basically
    {



    """""2.well i placed your code like this below move_uploaded_file and after uploading some file it created download.html file with no download link so i took the source code to show you here it is......""<a href="uploads/"></a><br />""

    {
    move_uploaded_file($_FILES["file"]["tmp_name"],
    "upload/" . $_FILES["file"]["name"]);
    echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
    $file = fopen("downloads.php", "a") or exit ("Can't open downloads.php for editing");

    $to_add = "<a href=\"uploads/$name_of_upload_file\">$name_of_upload_file</a><br />";

    fwrite($file, $to_add);
    fclose($file);
    }
     
    flawlessking, Dec 24, 2008 IP
  5. rene7705

    rene7705 Peon

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    if you can use a java applet, try jumploader.com, use it in partitioned mode..
     
    rene7705, Dec 24, 2008 IP
  6. itvn

    itvn Peon

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    :D Please edit your php.ini, search for upload_max_filesize parameter and change it.
     
    itvn, Dec 24, 2008 IP
  7. masoko2

    masoko2 Peon

    Messages:
    166
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    masoko2, Dec 24, 2008 IP
  8. planemaniac

    planemaniac Peon

    Messages:
    49
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Right, do what itvn has suggested above. That's the main problem.

    What you're also doing is you're using my variable $name_of_upload_file without actually assigning it to anything. You'll need to add a line:

    $name_of_upload_file = $_FILES["file"]["name"];

    then it'll at least have a chance of working.
     
    planemaniac, Dec 24, 2008 IP
  9. flawlessking

    flawlessking Well-Known Member

    Messages:
    136
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #9
    hey thanx planemaniac its working now
     
    flawlessking, Dec 25, 2008 IP