Anyone that can link how to upload an save an image in an sql server?
Propably you can save the path and sabve the foto on a folder that you want but anyway whats the way?
And resizing your photos?
I serached lot to find that but didnt find anything ty
Uploading images and saving into sql
Moderator: General Moderators
-
killingbegin
- Forum Newbie
- Posts: 20
- Joined: Sun Feb 08, 2009 5:07 am
Re: Uploading images and saving into sql
As far as resizing, I really like the TimThumb script http://www.darrenhoyt.com/2008/04/02/ti ... -released/
Uploading, you can either use a BLOB and keep the binary data in the database - which can lead to a hefty DB size.
Or you can just upload it with a simple upload script - here is an example to get you started - http://www.tizag.com/phpT/fileupload.php
and just save the file path to the database and then just out the file path which is what I would recommend.
Uploading, you can either use a BLOB and keep the binary data in the database - which can lead to a hefty DB size.
Or you can just upload it with a simple upload script - here is an example to get you started - http://www.tizag.com/phpT/fileupload.php
and just save the file path to the database and then just out the file path which is what I would recommend.
Re: Uploading images and saving into sql
try below stuff i think u'll get wht u want...
say upload.php
confirm_up.php
Note: Its changing the file name also
say upload.php
Code: Select all
<form action="confirm_show.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<input name="ufile" type="file" id="ufile" size="29" />
<input type="submit" name="Submit" value="Submit" />
</form>
Code: Select all
<?php
// Your file name you are uploading
$file_name = $HTTP_POST_FILES['ufile']['name'];
// random 4 digit to add to our file name
// some people use date and time in stead of random digit
$random_digit=rand(0000,9999);
//combine random digit to you file name to create new file name
//use dot (.) to combile these two variables
$new_file_name=$random_digit.".jpg";
//set where you want to store files
//in this example we keep file in folder upload
//$new_file_name = new upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path= "upload/".$new_file_name;
$check=0;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "File Name : ".$new_file_name;
}
else
{
echo "Error";
}
}
?>-
killingbegin
- Forum Newbie
- Posts: 20
- Joined: Sun Feb 08, 2009 5:07 am
Re: Uploading images and saving into sql
Thanx lot guys rly hellpfull.
I just saved into my DB the path of the image and 'GG'.
also for the resizing code.
Tip make a upload form that you will get only the name of the image and echo
<img src="/scripts/timthumb.php?src=/images/whatever.jpg&h=150&w=150&zc=1" alt="" />
at the whatever.jpg the name will be your pic name.and etc
Gj ty
I just saved into my DB the path of the image and 'GG'.
also for the resizing code.
Tip make a upload form that you will get only the name of the image and echo
<img src="/scripts/timthumb.php?src=/images/whatever.jpg&h=150&w=150&zc=1" alt="" />
at the whatever.jpg the name will be your pic name.and etc
Gj ty