upload script

Discussion in 'PHP' started by salayhin, Sep 11, 2009.

  1. #1
    Here Is a sample upload script.
    But I cant upload any audio or video script with this script.
    Please help me i want to upload all supported audio file and at the same the add to database...Please help Me.


    <form enctype="multipart/form-data" action="uploader.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    <input type="submit" value="Upload File" />
    </form>


    $target_path = "uploads/";

    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ". basename( $_FILES['uploadedfile']['name']).
    " has been uploaded";
    } else{
    echo "There was an error uploading the file, please try again!";
    }

    //Insert into database
    $my_insert = mysql_query("insert into song_detail (song_ID,song_Title,description, user_id,album_ID,music_category_ID,singer_ID,song_name,song_Path,add_date) VALUES ('','$song_title','$song_description','$user_id','$album_id','$music_category_id','$singer_id','$song_title','$filepath','')") or die(mysql_error());
     
    salayhin, Sep 11, 2009 IP
  2. SubZtep

    SubZtep Member

    Messages:
    69
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    48
    #2
    What is the error exactly? Files with small sizes are ok? Maybe you just have to setup the upload limit and max post size limit in the php.ini file.
     
    SubZtep, Sep 11, 2009 IP
  3. salayhin

    salayhin Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    No there is no error massege.
    Data insert in database but no file uploaded in upload folder.

    Thanks For Reply.
     
    salayhin, Sep 11, 2009 IP
  4. SubZtep

    SubZtep Member

    Messages:
    69
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    48
    #4
    np. has write right for the directory? set 0777 right. and try it with small file firstly. is path ok? (the code looks like good)
     
    SubZtep, Sep 11, 2009 IP
  5. salayhin

    salayhin Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    No i ahve try this on localhost.
    Is there any free software for upload a audio file in php?
     
    salayhin, Sep 11, 2009 IP
  6. SubZtep

    SubZtep Member

    Messages:
    69
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    48
    #6
    If everything allright, I think delete the MAX_FILE_SIZE hidden tag and must be work.

    (By the way put the SQL insert into the IF statement, because don't save the failed uploads)
     
    SubZtep, Sep 11, 2009 IP
  7. salayhin

    salayhin Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks For Reply.
    I will try it.
     
    salayhin, Sep 11, 2009 IP
  8. SubZtep

    SubZtep Member

    Messages:
    69
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    48
    #8
    Cheers. :)
     
    SubZtep, Sep 11, 2009 IP
  9. salayhin

    salayhin Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    not working...same problem.
     
    salayhin, Sep 11, 2009 IP
  10. SubZtep

    SubZtep Member

    Messages:
    69
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    48
    #10
    SubZtep, Sep 11, 2009 IP
  11. prasanthmj

    prasanthmj Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    45
    #11
    prasanthmj, Sep 11, 2009 IP
  12. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #12
    uploadphpscript.net but u need to change the allowed extensions/file type array
     
    crivion, Sep 12, 2009 IP
  13. Dennis M.

    Dennis M. Active Member

    Messages:
    119
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #13
    You must have the default max_upload_size value in your php.ini. Perhaps 2 or 4M or something? Increase to 8 or 16M.

    Regards,
    Dennis M.
     
    Dennis M., Sep 12, 2009 IP
  14. mayz

    mayz Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    There is a ready and working Upload script at http://www.1afm.net/scripts/indexf.php ,check under the File MGMT category.
    Tell me if it helps,I can recommend more options for you
     
    mayz, Sep 13, 2009 IP
  15. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #15
    I use the same script, but my web site allows member to subscribe.

    How could I display each member's photo on their respective profile page?

    Thanks in advance.
     
    ketting00, Sep 13, 2009 IP