Forum Moderators: coopster
I have created a edit page where it shows all the information in the text box...Even it shows the 1 files which they uploaded...Besides the 1 uploaded files i have created 1 delete button...if they click delete button the value of file stored in the database will be null...
In the edit page after displaying the earlier uploaded files i am also displaying 1 fields where they can upload the files again...
The problem:
Suppose its displays 1 files name 1)test.php which comes from the databse.
If they dont upload a new file than test.php should be saved in the databse.
Right now if they dont upload than the value is entered null in the datbase...
any help will be very thankful.
$uploaddir = '../upload/';
$filename = preg_replace('/[^a-z0-9_\-\.]/i', '_', $l."_".$f);
if (file_exists($uploaddir.$filename.".uploaded"))
{
for ($user_number = 1; file_exists($uploaddir.$filename."_".$user_number.".uploaded"); $user_number++)
;
$filename = $filename."_".$user_number;
} if($_FILES['trans']['name'])
{
$ext = strrchr($_FILES['trans']['name'], '.');
$upd_file1 = $uploaddir.$filename."_trans".$ext;
$t=$filename."_trans".$ext;
if (!move_uploaded_file($_FILES['trans']['tmp_name'], $upd_file1))
die("Unable to upload file ".$_FILES['trans']['name']);
}
if($_FILES['ref1']['name'])
{
$ext = strrchr($_FILES['ref1']['name'], '.');
$upd_file2 = $uploaddir.$filename."_ref1".$ext;
$r1=$filename."_ref1".$ext;
if (!move_uploaded_file($_FILES['ref1']['tmp_name'], $upd_file2))
die("Unable to upload file ".$_FILES['ref1']['name']);
}
if($_FILES['ref2']['name'])
{
$ext = strrchr($_FILES['ref2']['name'], '.');
$upd_file3 = $uploaddir.$filename."_ref2".$ext;
$r2=$filename."_ref2".$ext;
if (!move_uploaded_file($_FILES['ref2']['tmp_name'], $upd_file3))
die("Unable to upload file ".$_FILES['ref2']['name']);
}
than
update query
If no file has been uploaded, do not attempt to overwrite the entry in the database.