Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: MP3 File Upload

  1. #1
    Banned
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MP3 File Upload

    Can anybody tell me, what the code is to upload MP3's to the server?

  • #2
    Regular Coder
    Join Date
    Jul 2007
    Posts
    135
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Exactly why are you uploading mp3's to a server?

    Allowing users to do that creates so much legal hassle and you have to make them verify that the .mp3 isn't copyrighted, then you still might get in legal trouble... Ahhhh!!!

    Edit: I noticed that in your previous posts you uploaded images. It's pretty much the same thing...
    Just use "audio/mpeg3", instead of "image/jpg";

    A good file upload tutorial is here:
    http://www.tizag.com/phpT/fileupload.php

    Mime type list is here:
    http://www.webmaster-toolkit.com/mime-types.shtml
    Last edited by iceflyin; 10-28-2007 at 09:39 AM.

  • #3
    Banned
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Exactly why are you uploading mp3's to a server?
    Because there part of a theme I created. If you are the copyright holder, then there is no problems. - Correct?

    Edit: I noticed that in your previous posts you uploaded images. It's pretty much the same thing...
    Just use "audio/mpeg3", instead of "image/jpg";
    Is my previous code secure?

  • #4
    Regular Coder
    Join Date
    Jul 2007
    Posts
    135
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Secure? As in...

    Somebody uploading a file like "hack.php" and doing you in... Yea, as long as you only allow uploads with checking the mime type. Also, make sure to prevent SQL injection in any of your form fields by verifying input, or just adding slashes for now.

    There is no such thing as 100% secure... Eg: My friend doesn't store any php files in his public directory's, he includes them from server root folders.

    <? include_once('../'._$SERVER['DOCUMENT_ROOT'].'.files'); ?>

    Heck, even facebook messed up their php install and a couple of their php files went public a month ago, index.php, and profile.php

    Of course, theres session hijacking, cross server script hacks... etc... etc... It goes on forever. If you need your sessions to be secure, google "php tokens secure sessions".

    Balance security with usability! Note that until like a couple months ago... MySpace had every single vulnerability in existence... It was ridiculous! When websites get big, all the vulnerabilities get exploited.
    http://phpsec.org/projects/guide/2.html
    Last edited by iceflyin; 10-28-2007 at 11:22 AM.

  • #5
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Upload Mp3 to SQL Server

    Hi I am having the same problem i did what you said and it's still not working

  • #6
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Upload Mp3 to SQL Server

    I got an error

    Maximum request length exceeded.

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    We can't help you if you post your code but it sounds like there is a filesize limit on your uploads.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,470
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    The filesize limit within PHP config file, and/or your webhost themselves have the limit.

  • #9
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Upload Mp3 to SQL Server

    I'm using asp.net vb, but it worked i inserted it into a binary field in SQL Server, using the same code i would for image upload like you said, but i tried to pull it from the SQL Server like i would an image using response.binary write and it field the page with a bunch of symbols, how do i play it from the sql server?

    code below to insert

    Dim intImageSize2 As Int64
    Dim strImageType2 As String
    Dim ImageStream2 As Stream

    ' Gets the Size of the Image
    intImageSize2 = malbum2.PostedFile.ContentLength

    ' Gets the Image Type
    strImageType2 = malbum2.PostedFile.ContentType

    ' Reads the Image
    ImageStream2 = malbum2.PostedFile.InputStream

    Dim ImageContent2(intImageSize2) As Byte
    Dim intStatus2 As Integer
    intStatus2 = ImageStream2.Read(ImageContent2, 0, intImageSize)

    ' Create Instance of Connection and Command Object
    Dim MyConnection As New SqlClient.SqlConnection("Data Source=jrome.db.4961680.hostedresource.com; Initial Catalog=jrome; User ID=jrome; Password=Richard0583;")
    Dim str As String
    str = ("INSERT INTO music (title, artist, album, genre, year, song, image)" & "VALUES (@title, @artist, @album, @genre, @year, @mp2, @image)")
    Dim MyCommand As New SqlClient.SqlCommand

    MyCommand = New SqlClient.SqlCommand(str, MyConnection)
    'Add Parameters to Query


    MyCommand.Parameters.AddWithValue("@title", mtitle.Text)
    MyCommand.Parameters.AddWithValue("@artist", martist.Text)
    MyCommand.Parameters.AddWithValue("@album", malbum.Text)
    MyCommand.Parameters.AddWithValue("@genre", mgenre.Text)
    MyCommand.Parameters.AddWithValue("@year", myear.Text)
    MyCommand.Parameters.AddWithValue("@mp2", msong2.FileBytes)
    MyCommand.Parameters.AddWithValue("@song", malbum2.FileBytes)
    MyCommand.Parameters.AddWithValue("@image", malbum2.FileBytes)
    MyConnection.Open()
    MyCommand.ExecuteNonQuery()
    MyConnection.Close()

    code below to pull from sql server

    Dim myConnection As New Data.SqlClient.SqlConnection("Data Source=whsql-v22.prod.mesa1.secureserver.net; Initial Catalog=mgclient; User ID=mgclient; Password=Richard0583;")
    Dim myCommand As New Data.SqlClient.SqlCommand("Select image from projects where clientusername='" & (name.Text) & "' " _
    & "AND projectid='" & (imageid.Text) & "';", myConnection)


    Try
    myConnection.Open()
    Dim myDataReader As Data.SqlClient.SqlDataReader
    myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

    Do While (myDataReader.Read())

    Response.BinaryWrite(myDataReader.Item("image"))

    Loop

    myConnection.Close()


    Catch SQLexc As Data.SqlClient.SqlException

    End Try


  •  

    Posting Permissions

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