well try to use this (not quite what you asked)
if you are running under Win, remember to grant access to folder(write)
also remember to use :
<form name="TheForm" method="post" action="da.php" enctype="multipart/form-data">
/* if modifying */
$real_name = modifyFile($HTTP_POST_FILES,"picture",$pic_path,"picture",$afile);
/* adding new */
$real_name = addFile
($HTTP_POST_FILES,"picture",$pic_path);
functions are....
function random_name() {
list($usec, $sec) = explode(' ', microtime());
return round((float) $sec + ((float) $usec * 100));
srand(make_seed());
$randval = rand();
}
function addFile($HTTP_POST_FILES,$fileField,$filePath) {
if($HTTP_POST_FILES[$fileField]['name'] != "") {
if (is_uploaded_file($HTTP_POST_FILES[$fileField]['tmp_name']))
$the_file = $HTTP_POST_FILES[$fileField]['name'];
if(file_exists($filePath . $the_file)) {
$f_strt_pos = strpos($the_file, ".");
$f_type = substr($the_file,$f_strt_pos);
$ren_file = random_name() . $f_type;
$real_name = $ren_file;
move_uploaded_file($HTTP_POST_FILES[$fileField]['tmp_name'], $filePath.$ren_file);
$real_name = $real_name;
return $real_name;
} else {
move_uploaded_file($HTTP_POST_FILES[$fileField]['tmp_name'], $filePath.$the_file);
$real_name = $the_file;
return $real_name;
}
} else {
$real_name = "";
return $real_name;
}
}
function modifyFile($HTTP_POST_FILES,$fileField,$filePath,$dbField,$thePic) {
if($thePic != $HTTP_POST_FILES[$fileField]['name'] && $HTTP_POST_FILES[$fileField]['name'] != "") {
$real_name = "";
if (is_uploaded_file($HTTP_POST_FILES[$fileField]['tmp_name'])) {
$the_file = $HTTP_POST_FILES[$fileField]['name'];
if(file_exists($filePath . $the_file)) {
$f_strt_pos = strpos($the_file, ".");
$f_type = substr($the_file,$f_strt_pos);
$ren_file = random_name() . $f_type;
$real_name = $ren_file;
move_uploaded_file($HTTP_POST_FILES[$fileField]['tmp_name'], $filePath . $ren_file);
} else {
move_uploaded_file($HTTP_POST_FILES[$fileField]['tmp_name'], $filePath . $the_file);
$real_name = $the_file;
}
}
$real_name = $dbField."= '".$real_name."'";
} else {
$real_name = $dbField. "= '".$thePic."'";
}
return $real_name;
}
<form name="formi" method="post" action="" enctype="multipart/form-data">