Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7971103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:33:48+00:00 2026-06-04T07:33:48+00:00

Using a custom DevExpress application our users are uploading PDF files which get stored

  • 0

Using a custom DevExpress application our users are uploading PDF files which get stored in a VARBINARY(MAX) column on a MSSQL 2008 database.

I have LAMP box which successfully connects to that database using the FreeTDS driver.

I’m able to retrieve other types of information (images stored as blobs, dates, strings etc) but when I try to serve PDFs they become corrupted somehow.

If I do a comparison of the file before upload and after download using a hex editor I can see they are different (the string in the after shot matches what is on the db 128B08…)

Before and after

The PHP I am using to serve the file:

<?php
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public"); 
header("Content-Description: File Transfer");
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename=" . $arr[0]['FileName']);
header("Content-Transfer-Encoding: binary");
echo $arr[0]['FileContent'];

The C# used to save the file to the db:

public void LoadFromStream(string fileName, Stream stream)
{
  Guard.ArgumentNotNull(stream, "stream");
  Guard.ArgumentNotNullOrEmpty(fileName, "fileName");
  FileName = fileName;
  byte[] bytes = new byte[stream.Length];
  stream.Read(bytes, 0, bytes.Length);
  Content = bytes;
}

public void SaveToStream(Stream stream)
{
  if (string.IsNullOrEmpty(FileName))
  {
    throw new InvalidOperationException();
  }
  stream.Write(Content, 0, Size);
  stream.Flush();
}

public byte[] Content
{
  get { return GetDelayedPropertyValue<byte[]>("Content"); }
  set
  {
    int oldSize = size;
    if (value != null)
    {
      size = value.Length;
    }
    else
    {
      size = 0;
    }
    SetDelayedPropertyValue<byte[]>("Content", value);
    OnChanged("Size", oldSize, size);
  }
}

I’ve read just about every article I can find by searching “php varbinary, php output stream, php varbinary stream, varbinary encoding”. Help or suggestions much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:33:49+00:00Added an answer on June 4, 2026 at 7:33 am

    There’s a couple of problems with this.

    First off, the data stored in the database is in Hex format so you’ll need to convert that back to a byte array in your PHP code before serving it to the user.

    Secondly, the hex reprisentation you’ve got in the database doesn’t seem to be correct for the PDF you’re using.

    When I converted the PDF from a byte array to a hex reprisentation I got a very different looking Hex string that when converted back to a byte array, works fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hii, I am using devexpress xtrascheduler.In this i have created one custom form which
First question how to add custom column to aspxgridview column using looping to get
I have started using custom intents in my application and I have come across
When using custom dialog windows in a MVVM application, do you think it´s Ok
I am creating custom code snippet templates using DevExpress' CodeRush. Is there anyway for
I am using custom attributes to implement theme switching in my application. I have
How to Change Listview Color withour using custom listview? In my application the background
In my application I am using custom cell with a label and 4 unbuttons
In my application I'm using custom fields, with set*** methods wich changes some parameters
I'm using PropertyGrid control for editing some objects in my application. I'm using custom

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.