Jump to content

Recommended Posts

I can load a blob field to a MySQL database, but I get a size restriction.  I use the following code:

      $binFile = $uploadfile;
      $imgLocation = str_replace("\\","/", $binFile);

      $handle = fopen($binFile, "rb");
      $data=addslashes(fread($handle, filesize($binFile)));
      $strDescription = addslashes(nl2br($txtDescription));
      mysql_connect($database, $username, $password);
      @mysql_select_db($database) or die("Unable to select database");
      $query="Update contacts set Tif_file='$data', email='test2', fname='$basefilename' where first = 'Alexa'";
      if (mysql_query($query)) {
          echo "Successful write<br>";
      } else {
          echo "Failed write<br>";
          echo mysql_errno() . ": " . mysql_error() . "<br>";
      }
fclose($handle);

For small files, it uploads perfectly.  For larger files, it fails.  I think I can change the parameter on MySQL to allow a bigger file to be uploaded to the blob field. 

So, I tried to upload the bigger files to SQL Server 2000 instead of MySQL.  I can't upload those files because it would fail each time it encountered an apostrophe.  I can't change the apostrophe to another character because it's a TIF file that I'm trying to upload.  I used the same file to upload to the SQL Server 2000 database as I used to upload to the MySQL.

Anyone have any success uploading big files to SQL Server using php?  I used to do it in VB - I loaded the tif into a stream and then put it in the file.  Anyone have any source code to do this?

THanks!
Link to comment
https://forums.phpfreaks.com/topic/14973-load-blob-field-to-sql-server/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.