Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
March 16, 2010, 04:27:16 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
WB 2.8.1 released!
Download and additional information are available
here
.
110108
Posts in
15906
Topics by
9274
Members
Latest Member:
someWBUser
WebsiteBaker Community Forum
English
Help & Support
(Moderators:
Argos
,
BerndJM
)
BLOBS are corrupted with template data
Pages:
[
1
]
Author
Topic: BLOBS are corrupted with template data (Read 175 times)
andreww
Offline
Posts: 4
BLOBS are corrupted with template data
«
on:
February 07, 2010, 06:31:14 AM »
I have an upload form that uploads files (txt,pdf,bin etc..) to a MYSQL table as a blob. The files are valid when saved in the table as a blob. My download script retrieves the data, but when it's extracted as an attachment, it saves it with template html code corrupting the file. Is there anyway to strip/filter out the HTML/template code from the attachment when it prompts to save the file?
Thanks.
Logged
Argos
Forum administrator
Online
Posts: 1324
Re: BLOBS are corrupted with template data
«
Reply #1 on:
February 07, 2010, 12:07:38 PM »
What is a blob? What upload and download scripts do you mean? Are you talking about WebsiteBaker at all?
Logged
Jurgen Nijhuis
Argos Media
www.argosmedia.nl/portfolio
(mostly WB sites)
----------------------------------------------------------------
Please don't request personal support, use the forums!
andreww
Offline
Posts: 4
Re: BLOBS are corrupted with template data
«
Reply #2 on:
February 07, 2010, 06:33:04 PM »
BLOBS (Binary Large Objects) is a data type in a MYSQL database. I have the following forms/code inside a Web Baker template. See below
Upload a file form -
<form method="POST" enctype="multipart/form-data" action="upload.php">
<table width="350" cellspacing="1" cellpadding="1" border="0" class="box">
<tbody>
<tr>
<td width="246"><input type="FILE" name="userfile" id="username" /></td>
<td width="80"><input type="submit" value="Upload" name="upload" /></td>
</tr>
</tbody>
</table>
</form>
///---Inserts the file into the MYSQL database
include 'library/config.php';
include 'library/opendb.php';
//replace the above two string's with your database specific values
$sql="SELECT id, name ";
$sql .="FROM Upload.upload";
$sql_results = mysql_query($sql);
echo "<TABLE BORDER=1 cellspacing=0 cellpadding=5>";
echo "<TR><TD>File Link</TD><TD>Name</TD></TR>";
while ($rs = mysql_fetch_array($sql_results))
{
echo "<TR><TD><a href=download.php?id=".$rs[0].">". $rs[1]."</a></TD>";
echo "<TD>". $rs[1] ."</TD>"; //Name
}
echo "</table>";
echo "<P></P>* Click on the file name to download the file";
//----Downloads the file stored in the MYSQL Database. When this happens and this code is incorporated in a web baker template the attachment/save as file is corrupted with template data - corrupting the file in the process.
include 'library/config.php';
include 'library/opendb.php';
$id=$_GET['id'];
$sql = "SELECT content, type, name, ";
$sql .="size FROM Upload.upload WHERE id=$id";
$result = @mysql_query($sql);
mysql_result($result, 0);
$data = @mysql_result($result, 0, "content");
$type = @mysql_result($result, 0, "type");
$name = @mysql_result($result, 0, "name");
$size = @mysql_result($result, 0, "size");
include 'library/closedb.php';
header("Content-type: $type");
header("Content-length: $size");
header("Content-Disposition: attachment; filename=$name");
header("Content-Description: PHP Generated Data");
echo $data;
//---
The download code above extracts the file correctly, but is corrupted with the template data when it saves the file. Is there anyway to filter out the web baker template code from the attachment. I modified the code template to a blank template, but a small piece of code still gets attached to the attachment if that makes sense upon downloading and saving the file from the database. Any help would be appreciated.
Thanks.
Logged
Argos
Forum administrator
Online
Posts: 1324
Re: BLOBS are corrupted with template data
«
Reply #3 on:
February 07, 2010, 11:58:13 PM »
You talk about "Webbaker" and about a folder called "/library". This is the forum about Web
site
Baker and there is no folder called /library in WebsiteBaker. Are you talking about WebsiteBaker?
Even if so, your question seems to have little to do with WB, it looks like some general PHP/database related problem...
Logged
Jurgen Nijhuis
Argos Media
www.argosmedia.nl/portfolio
(mostly WB sites)
----------------------------------------------------------------
Please don't request personal support, use the forums!
andreww
Offline
Posts: 4
Re: BLOBS are corrupted with template data
«
Reply #4 on:
February 08, 2010, 04:11:33 PM »
The code above works fine outside of Website Baker. When this code is incorporated inside a Website Baker code template it spits out the contents with the attachment, corrupting it. It's not a code/php issue. It's to do with the templates outputting page content. I need the blank template for example to output absolutely nothing if it's possible. It seems like the blank template still outputs a one line of code corrupting the file.
Logged
Argos
Forum administrator
Online
Posts: 1324
Re: BLOBS are corrupted with template data
«
Reply #5 on:
February 08, 2010, 04:16:21 PM »
Maybe Code2 works better?
http://www.websitebakers.com/pages/admin/core-replacements/code-2.php
Logged
Jurgen Nijhuis
Argos Media
www.argosmedia.nl/portfolio
(mostly WB sites)
----------------------------------------------------------------
Please don't request personal support, use the forums!
andreww
Offline
Posts: 4
Re: BLOBS are corrupted with template data
«
Reply #6 on:
February 08, 2010, 05:06:34 PM »
Thanks. It's resolved. It had everything to do with the template I was using.
Logged
Pages:
[
1
]
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
=> Security Announcements
=> Documentation
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> Help & Support
=> Modules
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
=> jQuery
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
=> Archive (posts up to 2007)
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> Hilfe/Support
=> Module & Snippets
=> Templates & Design
=> Tutorials
=> jQuery
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
Loading...