Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Uploading a PDF to a folder

pdf

  • Please log in to reply
5 replies to this topic

#1 Pedro Amorim

Pedro Amorim

    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 27 May 2011 - 05:51 AM

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.

  • 0

#2 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 28 May 2011 - 09:09 AM

What does it do instead?
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#3 johnhardy009

johnhardy009

    CC Newcomer

  • Just Joined
  • PipPip
  • 14 posts

Posted 08 June 2011 - 01:51 AM

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

#4 yassinebelkaid

yassinebelkaid

    CC Newcomer

  • Just Joined
  • PipPip
  • 19 posts

Posted 21 August 2011 - 02:36 PM

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;)
  • 0

#5 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 21 August 2011 - 06:41 PM

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!
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#6 yassinebelkaid

yassinebelkaid

    CC Newcomer

  • Just Joined
  • PipPip
  • 19 posts

Posted 22 August 2011 - 10:41 AM

Hi dargueta, ok I understand that, I will not do it again.

Thank you.
  • 0





Also tagged with one or more of these keywords: pdf

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download