Advanced Search

Results 1 to 3 of 3

Thread: file upload audio/wave

  1. #1
    Join Date
    Mar 2009
    Location
    NJ, USA
    Posts
    32
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default file upload audio/wave

    Hello Dynamic Drive, I have a problem which I sadly could not resolve searching the forum. I want to have the user upload .wav files. I then want the file information displayed, and the file stored.

    The condition ($_FILES["file"]["type"] == "audio/wave") or "audio/wav" seem to be incorrect so I removed it from my code to make sure the rest of my code was working. This is where I become truly confused. I can upload any type of file except .wav files. When I try to upload a wave it echos "Error 2".

    I'm posting my code without the file[type] condition. I would like to know if there is any way to upload only wave files if at all.

    My Form:
    Code:
    <form action="submit_sample.php" method="post" enctype="multipart/form-data">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000"/>
    Upload sample: <input type="file" name="file" tabindex="1">
    <br>
    <input type="submit" value="Submit Sample" name="submit" tabindex="2">
    </form>
    My PHP:
    Code:
    <?php
    if ($_FILES["file"]["size"] < 900000) 
    // originally if (($_FILES["file"]["type"] == "audio/wave") && ($_FILES["file"]["size"] < 900000))
      {
      if ($_FILES["file"]["error"] > 0)
        {
        echo "Error: " . $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        echo "Upload: " . $_FILES["file"]["name"] . "<br />";
        echo "Type: " . $_FILES["file"]["type"] . "<br />";
        echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo "Stored in: " . $_FILES["file"]["tmp_name"];
        move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]);
        echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
        }
      }
    else
      {
      echo "Invalid file type or size";
      }
    ?>
    
    <a href="sample.php">Return to step 3</a>
    I'm really stuck here, any advice would be wonderful.
    Last edited by AdrielGreene; 03-08-2009 at 12:34 AM. Reason: Jason resolved my issue

  2. #2
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    Your MAX_FILE_SIZE is 100K

    UPLOAD_ERR_FORM_SIZE

    Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.

    http://www.php.net/manual/en/feature...oad.errors.php

    How big is the file you are trying to upload? My guess is that it is bigger than 100K.

  3. The Following User Says Thank You to JasonDFR For This Useful Post:

    AdrielGreene (04-09-2009)

  4. #3
    Join Date
    Mar 2009
    Location
    NJ, USA
    Posts
    32
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Thats it!!!

    Thank you so much Jason. That even resolved my original problem. I'll make sure to look over my html more carefully.

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
  •