Jump to content

Shazbot!

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Shazbot!'s Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, I had the same problem you are having of uploading an image to a mssql database and then downloading it for viewing. The issue was resolved and you can find my solution here. http://www.phpfreaks.com/forums/index.php/topic,146750.0.html The problem is the way you upload the data, there is an article in the thread that explains this. Hope this helps!
  2. ahh, that you for that. I forgot about that. I tried a different type of error and it worked.
  3. I just install PHP 5 on WinXP IIS (ISAPI) So far everything is working fine with the exception of the error handling. in the php.ini file I have the following set. display_errors = On and I have tried: error_reporting = E_ALL error_reporting = E_ALL & E_NOTICE restarted services each time but to no avail. In my test file I have <? echo "this is an error" ?> Please help. oh and the phpinfo file says the the display_error is 'ON' in both Local and Master and the error reproting is 6135 php.ini is located in the C:\Windows dir.
  4. Greetings, I need some help in with an image upload/download. I am working on a site for my wife and she needs to upload an image to a database and then download the image. php 5 with mysql 4 Problem is that when I try to display the image it shows up as garbled text (which I know is normal but I am not sure how to display it properly) The attached image is how it looks. Here is the upload code that I got from the net for uploading an image, this appears to be working. in MyPHP admin it shows the file size of the test image which looks right. mysql_select_db($database_OTH) or die( "Unable to select database"); //echo "<br />"; //echo "something else"; $fileName = $_FILES['imagefile']['name']; $tmpName = $_FILES['imagefile']['tmp_name']; $fileSize = $_FILES['imagefile']['size']; $fileType = $_FILES['imagefile']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } require_once('DBConnect'); $File_SongName="Unknown"; if(isset($_POST['File_SongName'])) { $File_SongName=$_POST['File_SongName']; } $File_SongVersion="1"; if(isset($_POST['File_SongVersion'])) { $File_SongVersion=$_POST['File_SongVersion']; } $File_Uploaded_By=$_SESSION['FULLNAME']; $TimeStamp=date('M-d-Y')." ".date('h:i:s A'); echo $_SESSION['FULLNAME']; $query = "INSERT INTO TableName(File_Name, File_Size , File_Type , File_Contents, File_Uploaded_By, File_SongName, File_SongVersion, File_Date_Uploaded) ". "VALUES ('$fileName', $fileSize, '$fileType', '$content', '".$_SESSION['FULLNAME']."', '$File_SongName', '$File_SongVersion', '$TimeStamp')"; mysql_query($query) or die('Error, query failed'); echo "<br>File $fileName uploaded<br>"; Here is the code to display the data through a download page: mysql_select_db($database_OTH) or die( "Unable to select database"); $query="SELECT File_ID, File_Name, File_Size FROM TableName WHERE File_ID=32";//.$_GET['FileID']; $SQL_Query=mysql_query($query) or die('Error, query failed'); while($Results=mysql_fetch_array($SQL_Query)) { //echo $Results['File_Name']; // echo "<br />"; //echo $Results['File_Size']; //echo "<br />"; header ("Content-Type: ".$Results['File_Type']."\n"); header ("Content-disposition: attachment; filename=\"".$Results['File_Name']."\"\n"); header ("Content-Length: ".$Results['File_Size']."\n"); readfile ($Results['File_Contents']); Thank you in advance for anyone that can help me. [attachment deleted by admin]
  5. Thanks ViN86, however, they will not allow PHP to have write permissions. Thanks frost110, Not my server and I have no access to to change any settings.
  6. I have a page that runs a query that totals the sums of totals for over 5000 people. The customer can then download this information. The process takes about 2 minutes and then the results are placed in a Session Variable. This is so the user can review the information without having to run the query again. The data is very large and I have noticed that it is slowing page navigation through the Intranet site. Is there another place where I can temporarily store this large data where it won't affect page surfing?
  7. Thanks chigley , That worked to some degree, the file will download corrupted because there is no content-length listed. If I add the content-length less than 999 it works, but the file is still corrupted. If the length is greater than 999 then it will stall and not download. Not saying that the content-length is causing the corruption but there is something happing here that is causing the file to be downloaded corrupted.
  8. I have successfully uploaded adobe .pdf's to a mssql 2005 server but now I am having issues downloading the file. in IE The download window will pop-up and ask to save or download. if Download is chosen it will begin the transfer but stalls and says connect to server timeout. if I open it I get binary description of the file. in Firefox The download window appears but the OK button is disabled. I have been searching for different methods of downloading the file and here is the code that I have: The file I am testing is only 213KB $file = mssql_fetch_array($result); //obtained from http://www.phpfreaks.com/forums/index.php/topic,141818.0.html header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Type: application/pdf"); header("Content-Disposition: attachment; filename=$file[3]"); header("Content-Transfer-Encoding: binary"); header("Content-Length: $file[2]"); readfile("$file[0]"); /* or header("Content-type: application/pdf"); //header("Cache-Control: public, no-cache"); //header("Content-type: application/octetstream"); header("Content-length: $row[2]"); //size header("Content-Disposition: attachment; filename=$file[3]"); header("Content-Description: File Transfer"); header("Content-Transfer-Encoding: binary"); // header("Content-Description: PHP Generated Data"); //readfile($file[0]); echo $file[0]; */ thanks in advance
  9. This topic has been solved and the answer has been posted here: http://www.phpfreaks.com/forums/index.php/topic,146750.0.html The issue revolved around how MSSQL inserts binary data http://us.php.net/manual/en/function.mssql-query.php#31688 Thanks to WildBug for the assist.
  10. Wildbug, Thanks for all your help, I have been working on this problem for quite some time now and it has been a pain. The article that you posted fixed the issue. I have successfully uploaded a .jpeg and .gif and downloaded it for viewing. I would never have figured it out without your help. Thanks a lot! here is the solution that work for me: Code to upload: require_once('Connect/conn.php'); $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $datastring= file_get_contents($tmpName); $data=unpack("H*hex", $datastring); $SQL="INSERT INTO Uploaded_Files(FILE_NAME, FILE_Type, FILE_Size, FILE_PID, FILE_Content) VALUES ('$fileName', '$fileType', '$fileSize', 8231954, 0x".$data['hex'].");"; echo $SQL; mssql_query($SQL) or die('Error, query failed'); code to view: require_once('Connect/conn.php'); $SQL="SELECT File_Content, File_Type FROM Uploaded_Files WHERE FILE_PID=8231954"; $SQL_Query=mssql_query($SQL); $result = mssql_query($SQL); $row = mssql_fetch_array($result); //$row[1] header("Content-type: $row[1]"); echo $row[0]; All I need to do now is validation and I should be set to go. Thanks again!
  11. I am not familiar with MySQL but you should be able to create an OBDC DSN (control panels, administrative tools, Data Sources) to the MySQL server and connect to the Access database and use Access as the front end. Create the DB in MySQL and use that as the primary and Access as the front-end.
  12. I am assuming that this is a MSSQL server you are connecting to so you need to change the mysql to mssql. You can also try to remove the () for the column names INSERT INTO users tracknum, username, address, state, city, phone, fax, email, groupn, isdone VALUES ('$tracknum', '$username', '$address', '$state', '$city', '$phone', '$fax', '$email', '$groupn', '$isdone')") finally, if any of your fields are of type int then you will need to remove the ' ' for the values.
  13. here is the code to display the image: require_once('Connect/conn.php'); $SQL="SELECT File_Content, File_Type FROM Uploaded_Files WHERE FILE_PID=8231954"; $SQL_Query=mssql_query($SQL); $result = mssql_query($SQL); $row = mssql_fetch_array($result); header('Content-type: image/gif'); //header('Content-type: $row[1]'); I have also tried this echo $row[0]; There is only 1 record in the database that is a .gif file. In FireFox I get an outline of the image and the following error: "image cannot be display because it contains errors." The source file shows the garbled text field "GIF89a ...." In IE it just shows an image place holder.
  14. hi, I am trying to upload an image to a MSSQL 2005 database and then download it for viewing. So far it appears that it is uploading correctly but it gives me errors when I am trying to view it. I posted the help topic in the main PHP Forums http://www.phpfreaks.com/forums/index.php/topic,146750.0.html but thought that I should ask here as well if anyone has any suggestions. The datatype for the image is image. Any help would be greatly appreciated. Thanks!
  15. unfortunately that did not work and the query to test it out on the SQL Server is SELECT LEFT(40,File_Content),LEN(File_Content) FROM LEAD_Uploaded_Files; This gives me the following error: So I am assuming that the uploaded image is not being converted to a binary file. Also, the view image script is displaying this message: GIF89a and some strange characters which cannot be posted here. I am hoping some else looking at this might have another idea? Thanks in advance!
×
×
  • 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.