I am making file uoload, but I want if the file already exists there to apear Message: "Do you want to replace it"
I tried to put in <INPUT TYPE="file" NAME="thepicture" VALUE=$thepicture> but this does't work. Please advise how can I place the file in the VALUE so there to be no need to Browse... to the same file again
Thank you
This is my code if it will help to understand me:
print "<FORM ACTION=\"all.php\" METHOD=POST ENCTYPE=\"multipart/form-data\">";
$imagedir=$DOCUMENT_ROOT."\images1\$thepicture_name";
if(($theform==1)AND($thepicture!="none")){
$result=mysql_query("select * from PICTURE where PICTURE='$thepicture_name'") or die(mysql_error());
$number_samepics=mysql_num_rows($result);
if(($number_samepics == 0)OR($replace == 1)){
if($thepicture_size<307200){ // 307200 ~= 300K
if(($thepicture_type=="image/gif")OR($thepicture_type=="image/pjpeg")){
if(copy($thepicture,$imagedir)){
$location = "images1";
$secret = 0;
$query="insert into PICTURE (PICTURE,LOCATION,SECRET)
values('$thepicture_name','$location','$secret')";
mysql_query($query) or die(mysql_error());
print "<b><center CLASS='red'>Picture upload - successful</center></b><br>";
print "<center CLASS='red'>The name of the picture is: <b>".$thepicture_name."</b></center>";
print "<center CLASS='red'>The size of the picture is: <b>".(((int)(($thepicture_size/1024)*100+0.5))/100)." K</b></center>";
print "<center CLASS='red'>The type of the picture is: <b>".$thepicture_type."</b></center><br>";
print "<center CLASS='red'>".$thepicture."</center><br>";
}else{
print "<center CLASS='red'><b>Can not copy file</b></center>";
} //end of - else - if(copy($thepicture,$imagedir))
}else{
print "<center CLASS='red'>Your file must be GIF or JPG!!! (it is: $thepicture_type )</center>";
} // end of - else - if(($thepicture_type=="image/gif")OR($thepicture_type=="image/pjpeg"))
}else{
print "<center CLASS='red'>Your file is too large: ".(((int)(($thepicture_size/1024)*100+0.5))/100)." K. It can be maximum 300K </center>";
} // end of else - if($thepicture_size<33000)
}else{
print "<center CLASS='red'>The picture with this name already exists - Do you want to replace it?</center>";
print "<center>Yes: <input type='radio' name='replace' value=1> No: <input type='radio' name='replace' value=2 checked></center>";
$toreplace = 1;
} // end of else - if($number_samepics==0) - if ther is the same pic name
}
print "<TABLE BORDER=1 CELLPADDING=3 align='center' CELLSPACING=0><tr><td align=right>";
print "Choose the <b>picture</b> for upload:</td><td><INPUT TYPE='file' NAME='thepicture'";
if ($toreplace == 1) print " VALUE='$thepicture'";
print ">";
print "</td></tr><tr><td align=right>";
print "<INPUT TYPE=SUBMIT NAME='Submit' VALUE='Upload Your Picture'></td><td>";
print "<INPUT TYPE=RESET NAME='Reset' VALUE='Reset'>";
print "<INPUT TYPE=HIDDEN NAME='theform' VALUE=1>";
print "<INPUT TYPE='HIDDEN' NAME='page' VALUE='picture_e'>";
print "</SELECT></td></tr></TABLE></FORM></body>";