Jump to content

witham

Members
  • Posts

    86
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

witham's Achievements

Member

Member (2/5)

0

Reputation

  1. Problem solved!! After much more digging and reading I managed to do this by including header('Content-Type: application/pdf'); at the very top of the script and to display the file // Display uploaded.pdf readfile($upfile); as the last function call. Thanks anyway I hope this helps someone else!!
  2. Thanks <html> <head> <title>Uploading...</title> </head> <body> <h1>Uploading file...</h1> <?php if ($_FILES['userfile']['error'] > 0) { echo 'Problem: '; switch ($_FILES['userfile']['error']) { case 1: echo 'File exceeded upload_max_filesize'; break; case 2: echo 'File exceeded max_file_size'; break; case 3: echo 'File only partially uploaded'; break; case 4: echo 'No file uploaded'; break; } exit; } // Does the file have the right MIME type? if ($_FILES['userfile']['type'] != 'application/pdf') { echo 'Problem: file is not pdf text'; exit; } // put the file where we'd like it $upfile = 'C:/uploads/'.$_FILES['userfile']['name']; if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $upfile)) { echo 'Problem: Could not move file to destination directory'; exit; } } else { echo 'Problem: Possible file upload attack. Filename: '; echo $_FILES['userfile']['name']; exit; } echo 'File uploaded successfully<br><br>'; // reformat the file contents $contents = strip_tags($contents); $fp = PDF_open_file($upfile, 'w'); fwrite($fp, $contents); ?> </body> </html>
  3. Hi thanks for your replay. All I really need to do is display the pdf in the browser after the upload.
  4. Hi I have written an upload script that restricts users from uploading anything other than pdf documents. After the php handles the upload and sends it to the directory I would really like to show a preview of the pdf that was uploaded. I have searched through the php.net website and have got really confused as to which pdf function to call. I assumed it would simply be PDF_open_file?? but I can't seem to get it to work. Before I continue it would be great to be certain that I am using the correct function. Thanks
  5. Thank you problem solved can't believe it was that simple.
  6. Hi I hope someone can help I have been searching the net for hours looking for a solution. I have mysql running through xampp on a laptop running windows vista. I also have the identical setup on a pc running xp which works perfectly. My issue is that whilst I can connect to phpmyadmin through localhost I cannot connect ant databases that have been imported from the xp setup. The error I get is below, I have tried to echo the Host and password ect but they don't appear? Could not connect to database server: \n"); // mysql_select_db selects a database to use on the database server //pointers to by $dblink // the @ sign before the command supresses any error messages @mysql_select_db ('weld' , $dblink) or die (" Could not connect to the database \n"); echo 'Host: '.$dbhost.' '; echo 'Username: '.$dbuser.' '; echo 'Password: '.$dbpass.' '; echo 'Database: '.$dbname; ?> Error Processing Query As the php works perfectly on xp setup I can't determine where the problem is??
  7. Just one more thing if I could ask how would I use an image as the link??
  8. Thanks very much its working now I had tried about every combination I could think of except that one.
  9. Thanks for you reply I have a database that contains various information input via a form this includes name, address and suchlike. Below is the array I want to display but I need the "compfile" to display as a hyperlink to the file. { // $row["fieldname" returns the content for the field in the current row echo "<tr><td>" .$row["MANNAME"]. "</td>"; echo "<td>" .$row["prodtype"]. "</td>"; echo "<td>" .$row["proddesc"]. "</td>"; echo "<td>" .$row["prodnar"]. "</td>"; echo "<td>" .$row["prodequiv"]."</td>"; echo "<td><a href=>" .$row["compfile"]."</td></tr>"; } // close html table tag echo "</table>\n";
  10. hi i am hoping someone can help me, I need to upload the path to a pdf file stored on the same machine. I have tried "file upload" but I can't seem to make it work. I will continue to try but I just need to establish if this is the correct piece of code to be using?
  11. Thanks very much for the assistance I have managed to connect.
  12. I hope someone can help I have set up xampp from apache friends on a laptop and written a php & mysql database which works fine. I loaded the same software, databases and php scripts onto another computer giving it the ip 192.168.0.5 but it will not connect: These are the variables I am using to try and connect: $dbuser = ''; // your database server user name $dbhost = '192.168.0.5'; // name of the sql server $dbpass = 'root'; // your database server password $dbname = 'weld'; // the name of the database to connect to and this is the mysql_connect and mysql_select_db // mysql_connect connects to the database server and returns a link to the the resource $dblink = @mysql_connect("$dbhost","$dbpass") or die("<p><b>Could not connect to database server: ($dbhost)</b></p>\n"); // mysql_select_db selects a database to use on the database server pointers to by $dblink // the @ sign before the command supresses any error messages @mysql_select_db ($dbname , $dblink) or die ("<p><b>Could not connect to database ($dbname)</b></p>\n");
  13. Hi I have a web application I am building and I would really like to navigate to a file so that this file path is subsequently rendered in a php script table as a link to the file. I have been reading alot about file upload but I don't think this is what I need as I only want to show the link where the file is and not actually upload it! This is the existing script: </select></td></tr> <tr><td class="style8">Product Name:</td> <td class="style8"><input type text name="ProdName"></td></tr> <tr><td class="style8">Product File Path:</td> [color=red]<td class="style8"><input type text name="FilePath"></td></tr>[/color] <tr><td class="style8">Product Equivalent:</td> <td><input type text name="ProdEquiv"></td></tr> The FilePath is the variable I want to pass to the script that handles the displaying of the link: { // $row["fieldname"] returns the content for the field in the current row echo "<tr><td>" .$row["MANNAME"]. "</td>"; echo "<td>" .$row["prodtype"]. "</td>"; echo "<td>" .$row["FilePath"]. "</td>"; echo "<td><a href=\"http://localhost/".$row["Compsheet"].".pdf\">".$row["Compsheet"]."</a></td>"; echo "<td>" .$row["prodequiv"]. "</td></tr>"; } // close html table tag echo "</table>\n"; I would be grateful if anyone could give me some assistance. Thanks
  14. Guys thats fantastic thanks for the help I appreciate it
  15. Hi I am hoping someone out there can help me with the final piece to a php script I am creating, let me explain. I have a page that allows users to query a database using two drop down boxes populated dynamically the page that processes the results of this query shows the data in a table. One of the columns of this table contains data which I really want to be links to files This is what I have presently but the link doesn't work when I click it?? // mysql_fetch_array fetches the results from the query a row at a time using a while loop each time it's called // the result is returned as an array that can be referenced either by field name or by it's index while ($row = mysql_fetch_array ($result)) // loop through the rows outputing them as html table rows { // $row["fieldname"] returns the content for the field in the current row echo "<tr><td>" .$row["MANNAME"]. "</td>"; echo "<td>" .$row["prodtype"]. "</td>"; echo "<td>" .$row["proddesc"]. "</td>"; echo "<td><a href>" .$row["Compsheet"]. "</td>"; echo "<td>" .$row["prodequiv"]. "</td></tr>"; } // close html table tag echo "</table>\n"; Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.