Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 9th, 2004, 02:14 PM
Registered User
 
Join Date: Jan 2004
Location: Blacksburg, VA, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help needed : Uploading of files

I am trying uploading of pdf files using PHP and Oracle.

Here is my code to upload the file.
Code:
/*************************************************************/
$main_query = "INSERT INTO submitted_material_list
                           (Application_Material_ID,
                            Application_ID,
                            Physical_Copy,
                            Rec_By,
                            Rec_Date)
               VALUES ($app_mat_id,
                       $app_id,
                       EMPTY_BLOB(),
                       $app_id,
                       SYSDATE)";
$result = $db->Execute($main_query);
$count = $count + 1;

$query1 = "SELECT MAX(application_material_id)
           FROM Submitted_Material_List";
$result1 = $db->Execute($query1);
$app_mat_id = $result1->fields[0];

if(!$db->UpdateBlobFile('Submitted_Material_List','Physical_Copy', $uploaddir,'application_material_id='.$app_mat_id,'BLOB'))
error('UpdateBlobFile() Failed : ', $db->ErrorMsg());
/*************************************************************/

Any idea as to how can I retrieve them from the database once they are uploaded ???
I need to upload multiple files and view multiple files.

Please help me on this,

Thank you for your reply in advance

Phpcoder

Nirali
Reply With Quote
  #2 (permalink)  
Old February 9th, 2004, 04:57 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

First, see this thread on this topic:
http://p2p.wrox.com/topic.asp?TOPIC_ID=9504

You may do multiple file uploads, but you'll want to check two configuration directives in php.ini:

1.) upload_max_filesize (2MB by default)
2.) post_max_size (8MB by default)

A database isn't the ideal place for large files anyway, think very small, be very careful with resource consumption!

To initiate download of a file, make your SELECT query and then do the following:
<?php
// query stuff

header('Content-Type: MIME TYPE HERE');
header('Content-Disposition: attachment; filename=proposed file name here');

// Output file contents
echo $file;
?>

The MIME type of a file e.g. image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash...

The proposed file name is what the user will be presented to save the file as.

If you want to view the file and the file is renderable in a browser.. either include a link to the script directly or call on the script in the 'src' attribute of relevant tags and omit the 'Content-Disposition' header call. You can use frames or iframes to view multiple files.

echo "<img src='file.php?id=$id' />";
echo "<iframe src='file.php?id=$id'></iframe>";

etc..

Also see:
http://www.php.net/manual/en/feature...ad.post-method

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
uploading files prognady ASP.NET 1.0 and 1.1 Professional 1 September 11th, 2006 06:15 AM
uploading files Atia Beginning PHP 1 January 28th, 2005 01:41 AM
uploading files rj1406 ASP.NET 1.0 and 1.1 Basics 1 October 11th, 2004 10:27 AM
Uploading Files sami PHP How-To 7 April 16th, 2004 02:29 PM



All times are GMT -4. The time now is 05:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.