Uploaded fielname as variable
Posted: Wed May 12, 2004 1:57 pm
Help!
I'm trying something real basic but I've been working at it for 8 hours+ with no light at the end of the tunnel.
All I want to do is upload a file ( mp3 ultimately, but any file will do ), and use the filename of this uploaded file, as a variable to be written into a .dat file.
When I have this filename written in the .dat file I can use it as part of a URL to link to the file.
But at the moment I only get the actual variable written to the file.
ie
This is what I have so far.
I'm trying something real basic but I've been working at it for 8 hours+ with no light at the end of the tunnel.
All I want to do is upload a file ( mp3 ultimately, but any file will do ), and use the filename of this uploaded file, as a variable to be written into a .dat file.
When I have this filename written in the .dat file I can use it as part of a URL to link to the file.
But at the moment I only get the actual variable written to the file.
ie
Please help...I make no money out of the site I run...so you won't be lining my pockets by sharing your knowledge!May 12, 2004, 6:33 pm|descriptive words|$file_url
This is what I have so far.
Code: Select all
<?php
$imagesdir = "../mp3/updir/";
$fp = fopen('../mp3/news.dat','a+');
$file_name = $_FILES['userfile']['name'];
$file_url = "../mp3/updir/".$file_name;
if($HTTP_POST_VARS['submit'])
{
$line = date ("F j, Y, g:i a"). "|" . $HTTP_POST_VARS['desc']. "|" . $HTTP_POST_VARS['tree'];
$line = str_replace("\r\n","<br>",$line);
$line = stripslashes($line);
$line .= "\r\n";
fwrite($fp, $line);
if (isset($_FILES['userfile'])) {
if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $imagesdir . $_FILES['userfile']['name'])) ;
{
echo ' ';
}
} else {
echo'';
}
}
$foom = $fishbaggerss
?>Code: Select all
<FORM ACTION="<?php echo $_SERVERї'PHP_SELF']; ?>" METHOD="POST" enctype="multipart/form-data" NAME="mp">
Upload MP3 File
<input type="file" name="userfile" id="userfile" >
<br>
Description;
<BR>
<TEXTAREA COLS="50" ROWS="2" NAME="desc">
</TEXTAREA>
<br>
<input type="hidden" name="tree" value=$file_url>
<BR>
<BR>
<INPUT TYPE="reset" NAME="reset" VALUE="r e s e t">
<INPUT TYPE="submit" NAME="submit" VALUE="P O S T">
<BR>
</FORM>