Forum Moderators: coopster
function movform()
{
global $link;
echo '<form action="addcon.php?op=movieinsert" method="post">'
. 'Movie Name: <input type="text" name="movname" /><br>'
. 'Movie Description: <input type="text" name="movdesc" /><br>'
. 'Movie Size: <input type="text" name="movsize" /><br>'
. 'Choose a file to upload: <input name="uploadedfile" type="file" /><br>'
. 'Movie Length: <input type="text" name="movlength" /><br>'
. 'Movie Type: <select name="movtype"><option value="trailer">trailer</option><option value="teaser">teaser</option><option name="gameplay">gameplay</option></select><br>';
$result = mysql_query("SELECT * FROM reviews order by title asc", $link) or die ("query 1: " . mysql_error());
echo 'Game Name: <select name="gameid">';
while ($row = mysql_fetch_array($result))
{
echo '<option value="'.$row['id'].'">'.$row['title'].'</option>';
}
echo '</select><br>'
. '<input type="submit" value="Insert Movie"/>';
}
function movin()
{
global $link, $row, $movname, $movdesc, $movsize, $uploadedfile, $movlength, $movtype, $gameid;
$target_path = "/gs/vids/";
$target_path = $target_path . basename( $_FILES['$uploadedfile']['name']);
if(move_uploaded_file($_FILES['$uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['$uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
$result = mysql_query("INSERT INTO vids (gameid, title, description, size, length, type) VALUES ('$gameid', '$movname', '$movdesc', '$movsize', '$movlength', '$movtype')", $link);
if (isset($result))
{
echo '<center>Movie Inserted</center>';
echo $target_path;
}
else
{
echo '<center>Insert Failed please go back and reinsert this movie</center>';
}
movform();
}
I dont know why but I keep getting the error There was an error uploading the file, please try again!
Anyone know how I can fix this?
enctype="multipart/form-data" So, the one line in your code would look like:
echo '<form action="addcon.php?op=movieinsert" method="post" enctype="multipart/form-data">'
there must be something wrong with this
$target_path = "/gs/vids/";
$target_path = $target_path . basename( $_FILES['$uploadedfile']['name']);
if(move_uploaded_file($_FILES['$uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['$uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
But I cant find it.
Anyone?
ChadSEO was right, you need that syntax in your upload form.
I think the problem is this variable:
$_FILES['$uploadedfile']['name']
Using the superglobal $_FILES means that this variable is available throughout the scope of your program and that includes inside functions. It doesn`t need to be declared as a global variable.
Try simply:
$_FILES['uploadedfile']['name']
$_FILES['uploadedfile']['tmp_name']
etc
dc
If you look in your httpd.conf file for apache for a directive called "Group", this will tell you the group that apache runs under. Alternatively, you can do
ps -ef ¦ grep httpd ¦ grep -v grep from a command line, and this will tell you the user that apache runs under - the group usually has the same name (ie httpd/httpd, nobody/nobody, etc.). Then, you will need to do a chgrp <apachegroup> /path/to/upload/folder, for example:
chgrp nobody /var/www/public_html/upload