Friday, May 21, 2010

What code (HTML, Perl, etc) would i use to allow users of my webpage to upload MP3's to my webpage?

you start with html


%26lt;form action="your.cgi"%26gt;


%26lt;input type="file" name="uploaded_file"%26gt;


%26lt;/form%26gt;





and your cgi written in perl makes use of the CGI library





use CGI;





and you access the file using


$filename = param('uploaded_file');





then you move it somewhere for you to check out later!





open(OUTFILE, "%26gt;%26gt;~/file$$.mp3" );


while ($bytesread=read($filename,$buffer,1024)... {


print OUTFILE $buffer;


}





You can add some more checks to make sure it's really an mp3, but not all your users will be able to send an mp3 as an mp3!

What code (HTML, Perl, etc) would i use to allow users of my webpage to upload MP3's to my webpage?
None! Upload is a function of the server, and there are a couple things to keep in mind!





1) Do you even have PERMISSION to let other people upload stuff to your webspace? Most web hosts only allow YOUR stuff on your webspace. Which means stuff YOU uploaded personally, not stuff uploaded by others.





2) Does the web host even HAVE an upload function? You can't let just anybody upload anything to a server. Hacker's first step is to get SOMETHING into the server. Once they are in, they can try to muck with the permissions, and eventually gain root access. Upload function is one of the easiest places to hack, actually, as it's not often checked.





3) How do you know they're actually MP3s, not warez or virii or spyware and stuff? Or for that matter, that they're "legal 2 trade" and not copyrighted MP3s?





4) How do I *limit* the number of uploads? Because if I go over I'll start owing much $$$$$? Most webspace are free, but limited to a few hundred megs, which MAY hold, assuming you don't have anything else, say about 80 MP3s (assuming 4 something megs each). If you manage to go OVER that, or there's a LOT of traffic on your space, you will be automatically bumped from the "free" to the "paid" account when you exceed your allocated bandwidth and space, and be billed automatically, and there'd be NO disputing this. If this is on a FREE host (such as Geocities), your account would IMMEDIATELY go into suspension .





Why don't you figure these out before you decide on the answer?
Reply:If your not stuck with using Perl, here's some tuts in asp:


http://www.asp101.com/resources/aspuploa...


http://www.asp101.com/resources/uploadin...


http://www.4guysfromrolla.com/webtech/Le...
Reply:html might
Reply:You would use an html form and a server back-end script to deal with the data sent to it, via the html form. Although I do suggest using PHP as your server side language, as it is my preference. But then again it's up to you. :D
Reply:You would need a form, in HTML, and "something" on the server side to accept the upload. If you're using Perl (which would be my preference) through CGI then you can use the CGI.pm module to handle the upload.





http://search.cpan.org/~lds/CGI.pm-3.27/...
Reply:if people are going to "upload " songs to your website (very doubtful ) you would need a ftp to your server that would allow them to do this ..





but i have to ask this , someone uploads a mp3 to your site , that you are not the copy write holder to , how long do u think the company hosting your site will allow this ?.


No comments:

Post a Comment