Re: How can i put the image file to the db ? (mssql)
From: ChronoFish (deja_at_chronofish.com)
Date: 11/11/03
- Next message: Kevin Thorpe: "Re: How much are PHP programmers paid in Germany?"
- Previous message: Kubaton Lover: "Serving PDF Problem"
- In reply to: Alper Adatoz: "How can i put the image file to the db ? (mssql)"
- Next in thread: pc_newbie: "Re: How can i put the image file to the db ? (mssql)"
- Reply: pc_newbie: "Re: How can i put the image file to the db ? (mssql)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 11 Nov 2003 09:25:33 -0500
"Alper Adatoz" <allper@myway.com> wrote in message news:eae08b72.0311110522.62b12fd3@posting.google.com...
> Hi,
>
> i have a little problem. i hope u guys give me a clear solution (:
>
> db: mssql
>
> i just want to put jpeg file to the image field at the mssql db.
>
> and after that i want to call it back..
>
> how can i do this ?
You can do this in PHP/MySQL, but you should develop this in an iterative stepwise fashion so that you understand what is happening.
Your code below has two issues. The first is uploading and saving a file. The second is saving binary date to a MySQL database.
> i tried this code ;
> $image = $_FILES['form_data']['name'];
> $image_yol = $_FILES['form_data']['tmp_name'];
> $newdata = "$image_yol";
> $data = addslashes(fread(fopen($image_yol, "r"),
> filesize($image_yol)));
>
With out getting too deep here, your first goal is to be able to upload and save a file - any file - graphic or otherwise. Here's a
hint. You are not going to be "addslashes" to the raw data - only to the data coming from the HTML form.
The PHP documentation is excellent and you will probably find some code you can copy and past from here:
http://www.php.net/manual/en/function.move-uploaded-file.php
> to put image to the db...
> but it gave me an error like
...
> do you have any idea?
>
The next step is saving data to the database. I assume you can save and retrieve text data from the database already. If not,
start there. Once you do that read up on "Blob" data types. The MySQL documentation is not laid out as well as PHP.net (in fact
PHP.net should be the model for document presentation... I digress...) but have fun searching for the information here:
http://www.mysql.com/documentation/mysql/bychapter/index.html
Now you can combine what you've learned and you will have your answer.
But as pointed out in another one of your responses, you may be better off saving the graphic to an "images" directory and then
simply saving the URL to the image in your database.
This would be easier on the database and will be easier to retrieve (you won't have to worry about sending HTTP header info when you
want to display the image from the database), but your requirements may not allow you to be this flexible (i.e. copywrite issues
won't allow a static URL to an image).
Hope this helps,
CF
- Next message: Kevin Thorpe: "Re: How much are PHP programmers paid in Germany?"
- Previous message: Kubaton Lover: "Serving PDF Problem"
- In reply to: Alper Adatoz: "How can i put the image file to the db ? (mssql)"
- Next in thread: pc_newbie: "Re: How can i put the image file to the db ? (mssql)"
- Reply: pc_newbie: "Re: How can i put the image file to the db ? (mssql)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|