SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2002
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Upload MP3's Prob...

    Hey all,
    I am trying to get my mp3Upload script to work. I think the problem is that I am trying to put it in a directory without proper perms on it. I have ssh'd in and chmod the folder to 777 and still get the following error:
    ERROR-------------------------
    File type is:audio/mpeg
    Warning: copy(/trax/clip1.mp3) [
    function.copy]: failed to create stream: No such file or directory in /home/starman/public_html/clients/relojRecords/logic/upload.php on line 32
    Problem: Could not move file into directory
    /ERROR-------------------------
    Thanks in advance,
    SUM
    P.S. Here's what I am doing now:
    CODE---------------------------
    $name=$_POST['name'];
    if ($userfile=="none")
    {
    echo "Problem: no file uploaded";
    exit;
    }

    if ($userfile_size==0)
    {
    echo "Problem: uploaded file is zero length";
    exit;
    }

    print("File type is:". $userfile_type);

    if ($userfile_type != "audio/mpeg")
    {
    echo "Problem: file is not plain text";
    exit;
    }
    $upfile = "/trax/".$userfile_name;
    if ( !copy($userfile, $upfile))
    {
    echo "Problem: Could not move file into directory";
    exit;
    }

    echo "File uploaded successfully<br><br>";
    $fp = fopen($upfile, "r");
    $contents = fread ($fp, filesize ($upfile));
    fclose ($fp);
    $contents = strip_tags($contents);
    $fp = fopen($upfile, "w");
    fwrite($fp, $contents);
    fclose($fp);
    echo "Preview of uploaded file contentsbr><hr>";
    echo $contents;
    echo "<br><hr>";
    ?>
    play hard

  2. #2
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    NJ/NY
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm.. $userfile I assume is the post variable sent from a form previously? These are long shots, but try removing the the first / slash in $upfile and make sure the 'trax' directory is at the right place.

  3. #3
    SitePoint Addict eddiembabaali's Avatar
    Join Date
    Mar 2001
    Location
    USA, Philadelphia
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may want to use is_uploaded file and move_uploaded_file. WHich version of php are you running anyway and what OS? Is register globals on?

    try using this as well:

    $userfile = $_FILES['userfile']['tmp_name'];
    $userfile_name = $_FILES['userfile']['name'];
    $file_size = $_FILES['userfile']['size'];
    cd pub \r; more beer

    Eddie


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
  •