Hi,
I lost one day and didn't find why this not work 🙁(.
I have a form with 4 file elements and submit the form to a php script.
In php script I can't get values for size, type and name of the uploaded files.
I mean if in the form I have
<input type="file" name="abc">
a can't get the values for the variables $abc_name, $abc_type, $abc_size.
Anyone can help me ?
I use Win98 OS.
Below is the source code for the 2 files.
The file with the form:
<head></head>
<body>
<form name="sas" action="new_card_add.php3" enctype="multipart/form-data">
Background<br>
<input name="fon_desc" type="text" size="30"><br>
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000">
<input type="file" name="fon" size="30"><BR>
Picture<BR>
<input name="k_desc" type="text" size="30"><br>
<input name="k" type="file" size="30"><BR>
Midi:<BR>
<input name="midi_desc" type="text" size="30"><br>
<input name="midi" type="file" size="30"><BR>
Picture for thumbnail<BR>
<input name="k_small_desc" type="text" size="30"><br>
<input name="k_small" type="file" size="30"><BR>
<input type="submit" value="OK">
</form></body>
The PHP script new_card_add.php3:
<?
include("pozdravi1/inc/config.inc");
mysql_connect($servername, $username, $password);
mysql_select_db($basenm);
$error_flag=0;
function add_binary($form_data,$form_description) {
global $error_flag;
if (!empty($form_data)) {
$data = addslashes(fread(fopen(stripslashes($form_data), "r"), filesize(stripslashes($form_data))));
if (!empty($data)) {
$result=MYSQL_QUERY( "INSERT INTO pozdravi_binary_data (description,bin_data,filename,filesize,filetype) ".
"VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')");
if ($result) {
$id= mysql_insert_id();
return $id;
}else{
return 0;
}
}else{
$error_flag=1;
return 0;
}
}else{
$error_flag=1;
return 0;
}
};
echo $fon_size."<br>";
echo $fon_name."<br>";
echo $fon_type."<br>";
echo $fon_desc;
$fon_id=add_binary($fon,$fon_desc);
if ( !$fon_id ) {$error_flag=1; $err_string.=mysql_error()."\n";};
$midi_id=add_binary($midi,$midi_desc);
if ( !$midi_id ) {$error_flag=1; $err_string.=mysql_error()."\n";};
$k_small_id=add_binary($k_small,$k_small_desc);
if ( !$k_small_id ) {$error_flag=1; $err_string.=mysql_error()."\n";};
$k_id=add_binary($k,$k_desc);
if ( !$k_id ) {$error_flag=1; $err_string.=mysql_error()."\n";};
echo $err_string;
?>