Jump to content

Uploading a PDF to a folder

- - - - -

  • Please log in to reply
5 replies to this topic

#1
Pedro Amorim

Pedro Amorim

    Newbie

  • Members
  • Pip
  • 4 posts
I was with some doughts were to put this thread, in databases or html, but since my problem ir more than a database problem, I'm going to ask you.

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.


#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,721 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
What does it do instead?
sudo rm -rf /

#3
johnhardy009

johnhardy009

    Newbie

  • Members
  • PipPip
  • 14 posts
Word to PDF, you can try free online pdf converter Zarmar.com (requires email).
Or desktop pdf conversion tool enolsoft pdf converter.

#4
yassinebelkaid

yassinebelkaid

    Newbie

  • Members
  • PipPip
  • 20 posts
I think it's better to separate your script into two files, one will hold only the form and the second will handle the script which will upload file. Like this, things will be organized ans easy to deal with, it's always a good practice to separate files. if you need further help, I'll be here to help.

Take care and Good Luck;)

#5
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,721 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Hi yass, welcome to CodeCall. Please try not to post on threads that are more than a few weeks old (this one is 2 1/2 months), as the people involved have most likely moved on, and it pushes newer threads down in the list.

Happy coding!
sudo rm -rf /

#6
yassinebelkaid

yassinebelkaid

    Newbie

  • Members
  • PipPip
  • 20 posts
Hi dargueta, ok I understand that, I will not do it again.

Thank you.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users