upload script
Posted: Sun Jul 31, 2005 6:04 am
hi there. i am putting a media page on my website which uses mysql. i have written the two scripts and everything is working apart form uploading. i dont know how to make it upload to a certain folder and the insert just the file name into the database (ie. upload from C:/my documents/web stuff/music/song.mp3 uploads it to a space on the server and adds song.mp3 to the database.)
the codes i have written so far are -
upload.php
upload2.php
thanks again
Eric
the codes i have written so far are -
upload.php
Code: Select all
<?php
include('http://eric.madashatters.com/header.inc')
?>
<center>
<div class="normalText">
<form action="http://eric.madashatters.com/media/upload2.php" method="post" name="post">
File Name -
<input type="text" name="name" size="48" class="textbox"><br>
<input type="hidden" name="date" size="48" class="textbox" value="
<?
echo date("dS M Y");
?>">
File -
<input type="file"><br>
Type -
<input type="text" name="type" size="48" class="textbox"><br>
Size -
<input type="text" name="size" size="48" class="textbox"><br>
<input type="submit" value=" Submit " class="textbox">
</form>
</div>
<SCRIPT language="JavaScript">
<!--
startclock();
//-->
</SCRIPT>
</center>
<?php
include('http://eric.madashatters.com/footer.inc')
?>Code: Select all
<?
include('http://eric.madashatters.com/header.inc')
?>
<?php
// Make a MySQL Connection
mysql_connect("localhost", "madashat_eric", "gateway2") or die(mysql_error());
mysql_select_db("madashat_media") or die(mysql_error());
if(get_magic_quotes_gpc())
{
$_POST["name"] = stripslashes($_POST["name"]);
$_POST["date"] = stripslashes($_POST["date"]);
$_POST["file"] = stripslashes($_POST["file"]);
$_POST["type"] = stripslashes($_POST["type"]);
$_POST["size"] = stripslashes($_POST["size"]);
}
$name = $_POST["name"];
$date = $_POST["date"];
$file = $_POST["file"];
$type = $_POST["type"];
$size = $_POST["size"];
mysql_query("INSERT INTO media
(name, date, file, type, size) VALUES('$name', '$date', '$file', '$type', '$size' ) ")
or die(mysql_error());
?>
<BR><BR><center>File Uploaded. <a href="http://eric.madashatters.com/">Return</a>!<BR><BR>
<?
include('http://eric.madashatters.com/footer.inc')
?>Eric