Page 1 of 1

Uploads

Posted: Mon Sep 27, 2004 9:16 pm
by robjime
Im trying to upload some files to some direcitories but its not going!

Code: Select all

<?php
echo $success;
?>
<form action="themeadd.php" method="post" enctype="multipart/form-data" name="form1">

  <table width="75%" border="0" cellspacing="2" cellpadding="0">
    <tr>
      <td>IMG Path:</td>
      <td><input name="img" type="file" id="img" value="<?php echo $img; ?>"></td>
    </tr>
    <tr>
      <td>Theme Name:</td>
      <td><input name="theme" type="text" id="theme" value="<?php echo $theme; ?>"></td>
    </tr>
    <tr>
      <td>Author: </td>
      <td><input name="author" type="text" id="author" value="<?php echo $author; ?>"></td>
    </tr>
    <tr>
      <td>Download Location:</td>
      <td>EXE: 
        <input name="exe" type="file" id="exe" value="<?php echo $exe; ?>">
        <br>
        LIN: 
        <input type="file" name="file" id="lin" value="<?php echo $lin; ?>"> </td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>User: 
    <input name="user" type="text" id="user" value="<?php echo $user; ?>">
    <br>
    Pass: 
    <input name="pass" type="password" id="pass">
    <br>
    <input type="submit" name="button" value="Submit">
  </p>
</form>
<?php
include("config.inc.php");
if(isset($_POST['button'])) {
$user = $_POST['user'];
$pass = $_POST['pass'];

$theme = $_POST['theme'];
$author = $_POST['author'];


if(empty($theme)){

$error .="error";
}
if(empty($author)){

$error .="error";
}

if(empty($user)){

$error .="error";
}
if(empty($pass)){

$error .="error";
}
if(!$user == $username && !$pass == $password) {
echo 'User or Password Wrong';
$error .="error";
}
$date = date("F j, Y, g:i a");
if(!empty($error)) {
echo "You missed a field or two";
}
 
else {
mysql_connect($dblocal,$dbuser,$dbpassword);
		@mysql_select_db($database) or die( "Unable to select database");

		$query = "INSERT  INTO  `themes` (  `id` ,  `img` ,  `theme` ,  `author` ,  `exe` ,  `lin` , `date` ) 
VALUES (  '',  '$img',  '$theme',  '$author',  '$exe',  '$lin', '$date' )";
		mysql_query($query);
		mysql_close();
$uploadfile = $uploaddir . $_FILES['img']['name'];
$uploadfile = $uploaddirlin . $_FILES['lin']['name'];
$uploadfile = $uploaddirexe . $_FILES['exe']['name'];

$success = "<b>Added entry into database</b>";

}
}
?>
As you can see it enters the values into the database, which it does, but the files don't upload? It does take a little longer to process the form than usual when the upload fields are filled in!

hmmm

Posted: Mon Sep 27, 2004 9:33 pm
by neophyte
I've been wanting to try writing a file upload script myself. Just haven't run into an opportunity yet. Have you found php.net yet?

Here's a place that might have a solution:

php.net

Posted: Mon Sep 27, 2004 10:58 pm
by feyd
are you sure the files don't upload? because you certainly haven't actually done anything with the uploaded files... tmp_name contains the path to the uploaded file. Use [php_man]move_uploaded_file[/php_man] to, well move them to where you want.