Reply to multiple files upload

multiple files upload new!
by Sergio, 16 years, 9 months ago
Hello,

I'm trying to implement this script to another that I'm using for a long time. That script has option for uploading photos but it can't optimize them and make thumbnails. Now, I want implement this code to that script.
The original part of PHP script for uploading before adding new code looks like this:

include_once C_PATH.'/classes/upload.class.php';
$time = time();
for($p = 0; $p <= 2; $p++) {
  $file = 'file'.$p;
  $k = $p+1;
  if (!empty($HTTP_POST_FILES[$file]['name']))   {
    if (!C_IMG_ERR)     {
      // If Unavailable image upload errors with UIN
      $dir = date("mY", $time);
      $slash = "/";
      if (!file_exists(C_PATH.'/members/uploads/'.$dir))
        {
        umask(0);
        mkdir (C_PATH."/members/uploads/".$dir, 0777);
      }
    } else $dir = $slash = "";
    $fb = date("dHis", $time);
    $fe = rand(0, 999);
    $fn = $fb."-".$fe;
    $intpic = $dir.$slash.$fn.'.';
    $u = new Upload($file, C_MAXSZ, C_MAXWD, C_MAXHG, C_PATH.'/members/uploads/'.$intpic);
    if (!$u->do_upload()) printm($u->getErrors());
    $mpic[$k] = ", pic".$k."='".$intpic.$u->getType()."'";
  }
}
 
/////////////
$last_id = $_SESSION['m'];
$usr = ((C_ID) || (!isset($username))) ? '' :
 "username='".$username."',";
mysql_query("UPDATE ".C_MYSQL_MEMBERS." SET ".$usr."fname='".$fname."',lname='".$lname."',birthday='".$year."-".$month."-".$day."',gender='".$gender."',
  purposes='".$purpose."',country='".$country."',email='".$email."',url='".$url."',
  icq='".$icq."',aim='".$aim."',phone='".$phone."',city='".$city."',marstat='".$marstat."',child='".$child."',height='".$height."',weight='".$weight."',hcolor='".$hcolor."',ecolor='".$ecolor."',etnicity='".$etnicity."',religion='".$religion."',smoke='".$smoke."',drink='".$drink."',education='".$education."',job='".$job."',hobby='".$hobby."',descr='".$descr."',sgender='".$sgender."',setnicity='".$setnicity."',sreligion='".$sreligion."',agef='".$agef."',aget='".$aget."',heightf='".$heightf."',heightt='".$heightt."',weightf='".$weightf."',weightt='".$weightt."',horo='".horo($month, $day)."',editdate=NOW(''),ip='".ip2int(ip())."',status='".$cst."' ".$mpic[1].$mpic[2].$mpic[3]." WHERE id='".$last_id."'") or die(mysql_error());

Problem is that this script is using for changing users profile. That means that there are already uploaded photos and recorded in database and now, when I add your code and use your class it overwrites those records in database and makes empty records in database for all fields that are empty in upload process.

For example, some user successfully register them self and PHP records all data in DB with 3 photos. After that, the same user want to change these pics and instead of second photos in his profile he want to put another second pics. When he try to do that the result is there is no ald photos in his profile and the new one that he want to upload is on first position.

How can I solve this problem.

Thanks a lot in advance.


Regards.Reply

Your reply

Name *
Email 
Title *
Text *
CAPTCHA image
Enter the code displayed on the image:
Click on the image to generate another one if it is hard to read it. The case is important