Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP/MySQL Problem

Options
2»

Comments

  • Closed Accounts Posts: 17 dagrog007


    If my problem is the header(Content-type: $content) code. Is there a way for PHP to convert the binary code back into an image?


  • Registered Users Posts: 6,509 ✭✭✭daymobrew


    dagrog007 wrote: »
    If my problem is the header(Content-type: $content) code. Is there a way for PHP to convert the binary code back into an image?
    As an experiment, hard-code the header string. [php]// Note the uppercase T in Type.
    header('Content-Type: image/jpeg');[/php] Note that it's an uppercase T in Type
    You could also save the binary data from your browser to a file to see if it is identical to the expected file.


  • Closed Accounts Posts: 25,848 ✭✭✭✭Zombrex


    What I love about this kind of question is the way that the PHP headers pile on and try to out-do eachother :D

    I'm a C++ header :eek:

    But I think it is more that anyone who uses PHP runs into all these types of problems, as it really is a hack of a little language. If something isn't working you can't be sure if you have done something wrong or it simply doesn't work*. It is a collective out pouring of sympathy for people starting off using it more than anything :D

    *getting better with each revision of PHP, but even trying to fix these problems with the language causes problems as they try to support and fix old nonsense at the same time.


  • Closed Accounts Posts: 17 dagrog007


    Hi daymobrew, I tried hard coding header('Content-Type: image/jpeg'); in to the file but the images are still not displaying.

    Cheers


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Hi again dagrog.

    Try the following:

    -Upload an image
    -Access the database table and copy the binary to the clipboard
    -Create a new file on your desktop, paste in the binary and save it with the extension .jpg
    -Open the file and compare with the original upload.


  • Advertisement
  • Closed Accounts Posts: 17 dagrog007


    Hey Mirror - I did as you said and the comparing the two files they are not 100% identical. I have attached the two if you want to have alook.
    In the database I dont have the option to save the image directly to a .txt file. I had to choose word 2000 and then when window asks you where to save I changed the file extension to .txt (I am not sure if this will make a difference to what appears in the text doc after it is saved). I then open the image in at .txt file and compared the two.


  • Registered Users Posts: 6,509 ✭✭✭daymobrew


    dagrog007 wrote:
    In the database I dont have the option to save the image directly to a .txt file.
    What other options are there? What does the data look like in Word? (not good I guess).

    I renamed the websiteError04.txt to .jpg but neither Firefox or GIMP could open it. Maybe it got corrupted on the way into or out of the database.

    All this trouble brings me back to the thumbnail issue I mentioned yesterday.
    Maybe you could store the uploaded file on the server, creating a thumbnail sized image at the same time. The thumbnail would be displayed in the page you are working on, with the link pointing to the original file.

    Of course, sticking with your current algorithm (store in db), when you've resolved the issue here, I recommend creating a thumbnail image and storing it in the db too.


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Ok, presumably you've tried this with a lot of different images and not just the same one repeatedly?

    It appears now that the image isn't making it to the database in correct binary format, as the two files are in fact basically identical, but for the output of special characters such as "<" in one file but "<" in the other.

    In other words:

    Image selected is fine
    Image is uploaded
    Image entry and output match
    Image output and original image uploaded don't match


  • Registered Users Posts: 6,509 ✭✭✭daymobrew


    Off to google we go...
    Is your code from weberdev.com? It uses test_imagedb_create.php as one of the scripts.


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Aye, knew I'd seen the code somewhere before!

    Read the comments at the bottom of the page dagrog, there are a couple of bugs mentioned.


  • Advertisement
Advertisement