First of all I'm new in HTML, all I now is from tutorials and scripts, so, please be pacient with me :D
I want to create a website were I can store some datacheats in pdf, so I created 3 steps
1º a form
<?php include ("upload/autentication.php"); ?>
<label for='model' >Model:</label>
<input type='text' name='model' id='model' maxlength="50" />
<form action="<?php print $PHP_SELF ?>" enctype="multipart/form-data" method="post">
<div class="insert_prod">PDF Data: <input name="uploadedfile" type="file" /><br /></div></form>
<input type='submit' name='Submit' value='Submit' class="link2"/>
<?php
if(isset($_POST['submit'])) {
$model= $_POST['model'];
$uploadfile= $_POST['uploadfile'];
$insert ="INSERT into table (model, uploadfile) values('$model', '$uploadfile')";
<?php include ("move.php"); ?>
}
2º autentication.php
<?php $hostname = '127.0.0.1'; $username = 'root'; $password = 'nopass'; $table = 'mywebsite'; $db = mysql_connect($hostname, $username, $password)or die(mysql_error()); mysql_select_db($table, $db); ?>
3º move.php
<?php
$filePath = "pdfs/";
$ff = mysql_insert_id();
$ext = explode(".", $_FILES['uploadfile']["tmp_name"]);
move_uploaded_file($_FILES['uploadfile']['tmp_name'], $filePath . $ff . $ext[1]))
$rr = mysql_query("UPDATE table SET uploadfile='" . $ff . $ext .
"' WHERE id_model='" . $ff . "'") or die(mysql_error());
?>
This should store the pdf to the pdfs folder and the address to the database, right? It is not working and I don't know why :(
Edited by dargueta, 28 May 2011 - 09:07 AM.


Sign In
Create Account

Back to top









