Results 1 to 4 of 4

Thread: need help with small php upload file script

  1. #1

    Thread Starter
    Addicted Member MoE70's Avatar
    Join Date
    May 2006
    Posts
    185

    need help with small php upload file script

    if you have apache please try to get this script to upload mp3 files. it keeps saying invalid file what ever i do.

    PHP Code:
    <?php
    if (($_FILES["file"]["type"] == "audio/x-ms-wma")
    || (
    $_FILES["file"]["type"] == "audio/mp3")
    && (
    $_FILES["file"]["size"] < 20000000000))
      {
      if (
    $_FILES["file"]["error"] > 0)
        {
        echo 
    "Return Code: " $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        

        if (
    file_exists("upload/" $_FILES["file"]["name"]))
          {
          echo 
    $_FILES["file"]["name"] . " already exists. ";
          }
        else
          {
          
    move_uploaded_file($_FILES["file"]["tmp_name"],
          
    "upload/" $_FILES["file"]["name"]);
          echo 
    "Stored in: " "upload/" $_FILES["file"]["name"];
          }
        }
      }
    else
      {
      echo 
    "Invalid file";
      }
    ?>
    Attached Files Attached Files

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: need help with small php upload file script

    my server running apache 2.2.4 with php 5.2.1 uploaded it fine. the mp3 file was 2.68mb in size and was named "2pac - last battle.mp3". script was completely unaltered, although i removed the index.html file. also added a "max_file_size" property to index.php's code.

    try it for yourself
    Last edited by kows; Mar 22nd, 2007 at 06:38 PM.

  3. #3

    Thread Starter
    Addicted Member MoE70's Avatar
    Join Date
    May 2006
    Posts
    185

    Re: need help with small php upload file script

    Quote Originally Posted by kows
    my server running apache 2.2.4 with php 5.2.1 uploaded it fine. the mp3 file was 2.68mb in size and was named "2pac - last battle.mp3". script was completely unaltered, although i removed the index.html file. also added a "max_file_size" property to index.php's code.

    try it for yourself

    it still says the same thing for me :/

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: need help with small php upload file script

    when you run the script on MY webserver? if that's so, then something is either wrong with your browser -- or maybe something to do with the file you're uploading. so, what browser are you using, and what type of file did you try to upload? how large was it? have you tried different files? does the file have the "mp3" file extension? have you tried using the stand-alone function mime_content_type() to find out what content-type it is returning on its own? (if you try this and get an error stating that the function does not exist, you'll need to enable the use of mime_magic in your PHP ini by changing mime_magic.debug to 1 or On and also verify that mime_magic.magicfile is a valid path to the mime_magic file in your PHP directory).

    if it just isn't working on your webserver; I assume you're using apache, but what version? and what version of php are you using? do you have file uploads enabled in your PHP ini file? is the file larger than the maximum allowed filesize that your PHP ini has set? any custom apache configuration that might have some adverse affect on the script? you might also want to check what mime type the file is returning via the instructions above in this case, too.

    edit: added a few things.
    Last edited by kows; Mar 27th, 2007 at 04:32 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width