Subject: Help needed : Uploading of files
Posted By: phpcoder Post Date: 2/9/2004 1:14:12 PM
I am trying uploading of pdf files using PHP and Oracle.

Here is my code to upload the file.

/*************************************************************/
$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 By: richard.york Reply Date: 2/9/2004 3:57:17 PM
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/features.file-upload.php#features.file-upload.post-method

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::


Go to topic 9555

Return to index page 952
Return to index page 951
Return to index page 950
Return to index page 949
Return to index page 948
Return to index page 947
Return to index page 946
Return to index page 945
Return to index page 944
Return to index page 943