Official Luthiers Forum!

Owned and operated by Lance Kragenbrink
It is currently Wed Nov 27, 2024 9:44 am


All times are UTC - 5 hours





Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject:
PostPosted: Tue Sep 25, 2007 3:47 pm 
Offline
Contributing Member
Contributing Member
User avatar

Joined: Wed Feb 15, 2006 7:37 am
Posts: 4805
Hi everyone

I'm working on a project that's asking me to dwelve into skills I happily
moved to the recesses of my mind. I'm building a PHP form that will have
a file upload function. I'd like to "echo" the name of the uploaded file into
another field. So I'm trying to do something that will look like this:

Upload file: upload button

mp3: text field

I'd like the uploaded file to automatically echo its name into the mp3's
text field.

The bigger picture is an audio player in flash for my church. They'll
upload the file, enter it's display information, and be done with it. The
form will add the info to a database, and another form will read the
database, compile it all into an XML array which Flash reads.   

Right now what I can do is upload the file, go to a new page upon
completion to enter the data and select the file from a drop down list. I'd
like to make it a one page, non drop down deal for efficiency and less
chance of user error.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 26, 2007 12:07 am 
Offline
Cocobolo
Cocobolo
User avatar

Joined: Sun Jun 18, 2006 12:23 am
Posts: 100
Location: Brisbane, Australia

So you want to click the "Browse..." button on the upload box, find the filename, click "Open" and have that filename appear automatically in a box below? I assume the idea is that if the filename is incorrect for the mp3 (track01.mp3, rather than the desired Artistname - Trackname.mp3), the person uploading will be able to edit what the text is, but to cut down time it'll automatically appear?


If this is the case, it'll be playing with some Javascript, in which case try Googleing along those lines ('javascript update form field from another' etc.). The key will be getting it to strip everything but 'filename' from 'C:/path/filename.mp3'


If all you want to do is get the just the filename.mp3 to save into a database, then it'll be a simple use of the basename( $_FILES['upload_field_name']['name']) after submitting to extract the filename, and using that in the appropriate SQL query.


Hope this helps... it beats actually getting to work on redoing my site.


_________________
Richard
http://www.guitarmaker.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 26, 2007 5:33 am 
Offline
Contributing Member
Contributing Member
User avatar

Joined: Wed Feb 15, 2006 7:37 am
Posts: 4805
Richo, thank you! The second example is perfect, even if it doesn't totally
make sense. I'm sure I'll ask you another question!

I can already upload the file and change the info. I'm trying to get that
filename into the database along with the other display info.

Thanks again!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 26, 2007 2:02 pm 
Offline
Cocobolo
Cocobolo
User avatar

Joined: Sun Jun 18, 2006 12:23 am
Posts: 100
Location: Brisbane, Australia

If you've got the upload working fine, then you will be using $_FILES[] probably a few times.


By using the basename() function around $_FILES['upload_field']['name'], it'll return just the 'filename.mp3'.


['upload_field'] will be whatever you've named the file upload field on the form. ['name'] just stays the same.


What I'd do is something like:


$filename = basename($_FILES['upload_field']['name'];


mysql_query("INSERT INTO songs SET (filename,etc.,etc.) VALUES ('$filename','$etc.','$etc.')");


_________________
Richard
http://www.guitarmaker.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
phpBB customization services by 2by2host.com