I have written a code to upload files to a directory but it only works if something is place in the upload files field. The problem arises when the upload file field is empty and you make changes to some of the other fields on the same form and it will not work.
Where am I going wrong? How can I tell cgi that when the upload file field is empty, this is okay and go ahead and process the form in the database with the changes from other fields.
the code
-------
##--------
# uploadImage()
##--------
sub uploadImage
{
# need this transfer the right size of the file
$upload_logo = param('logo1');
$logo1 = lc(join '', split / /,(split/\\/, param("logo1")[-1]);
# $upfile = lc(join '', split / /,(split/\\/, $logo1)[-1]);
$abs_file_to_create .= "/locato_on_web_server/";
$abs_file_to_create .= "$logo1";
open(NEW_FILE,">$abs_file_to_create" || die "Can't open $abs_file_to_create for output: $!";
binmode NEW_FILE;
while (read($upload_logo, $data, 8192))
{
print NEW_FILE $data;
}
close NEW_FILE;
}
Thank you for your knowledge, wisdom and time!
There
Where am I going wrong? How can I tell cgi that when the upload file field is empty, this is okay and go ahead and process the form in the database with the changes from other fields.
the code
-------
##--------
# uploadImage()
##--------
sub uploadImage
{
# need this transfer the right size of the file
$upload_logo = param('logo1');
$logo1 = lc(join '', split / /,(split/\\/, param("logo1")[-1]);
# $upfile = lc(join '', split / /,(split/\\/, $logo1)[-1]);
$abs_file_to_create .= "/locato_on_web_server/";
$abs_file_to_create .= "$logo1";
open(NEW_FILE,">$abs_file_to_create" || die "Can't open $abs_file_to_create for output: $!";
binmode NEW_FILE;
while (read($upload_logo, $data, 8192))
{
print NEW_FILE $data;
}
close NEW_FILE;
}
Thank you for your knowledge, wisdom and time!
There