Mit Chauhan
New member
JAI MATADI all . .
m uploading my image using PHP in which i m also using mysql for database ..
m uploading the photo(s) first in the directory called (upload) then m only uploading the foldername + imagename (i. e. - upload/image1.gif ) into mysql database .. and then fetching it into my webpage(s) also .. with this ..
but m getting one problem doing this .. if my i have already uploaded image called (image1.gif) and if the user again uploading it with the same name and extension then my previous image automatically removing the previously uploaded image and changing to this one ..
so what i want to do is if my image called (image1.gif) already uploaded then i want to rename it during my php code something like (image2.gif) ..
if (image2.gif) is there then again will increase to (image3.gif) etc etc . .
can anybody please tell me how to do this with code ..
here is my code for your kind information .. what m doing . .
-------------------------
mypage.php
------------------
<form method="post" enctype="multipart/form-data" name="f1" id="f1" >
<input type="file" name="file1" id="file1" />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
<?php
if(isset($_POST["submit"]))
{
mysql_connect("localhost","root","");
mysql_select_db("alldatabase");
$path1 = "upload/";
$path1 = $path1 . $_FILES["file1"]["name"];
$_FILES["file1"]["tmp_name"];
move_uploaded_file($_FILES["file1"]["tmp_name"],$path1);
$qry = "insert into signup (passport) values('$path1')";
if(!mysql_query($qry))
{
echo mysql_error();
}
else
{
echo "You have Successfully made your account";
}
}
?>
-------------------------
please tell me how can i check if the
please tell me how can i check if the image already exists or not .
and if it is already exists how can i renaming it .. with increment of numbers at the end of image name or something like that ..
any help will be so appreciated .. m at the stage of ending my project ..
thanks a lott ..
m uploading my image using PHP in which i m also using mysql for database ..
m uploading the photo(s) first in the directory called (upload) then m only uploading the foldername + imagename (i. e. - upload/image1.gif ) into mysql database .. and then fetching it into my webpage(s) also .. with this ..
but m getting one problem doing this .. if my i have already uploaded image called (image1.gif) and if the user again uploading it with the same name and extension then my previous image automatically removing the previously uploaded image and changing to this one ..
so what i want to do is if my image called (image1.gif) already uploaded then i want to rename it during my php code something like (image2.gif) ..
if (image2.gif) is there then again will increase to (image3.gif) etc etc . .
can anybody please tell me how to do this with code ..
here is my code for your kind information .. what m doing . .
-------------------------
mypage.php
------------------
<form method="post" enctype="multipart/form-data" name="f1" id="f1" >
<input type="file" name="file1" id="file1" />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
<?php
if(isset($_POST["submit"]))
{
mysql_connect("localhost","root","");
mysql_select_db("alldatabase");
$path1 = "upload/";
$path1 = $path1 . $_FILES["file1"]["name"];
$_FILES["file1"]["tmp_name"];
move_uploaded_file($_FILES["file1"]["tmp_name"],$path1);
$qry = "insert into signup (passport) values('$path1')";
if(!mysql_query($qry))
{
echo mysql_error();
}
else
{
echo "You have Successfully made your account";
}
}
?>
-------------------------
please tell me how can i check if the
please tell me how can i check if the image already exists or not .
and if it is already exists how can i renaming it .. with increment of numbers at the end of image name or something like that ..
any help will be so appreciated .. m at the stage of ending my project ..
thanks a lott ..