简体   繁体   中英

php image upload problem with move_uploaded_file function

i have one image upload script which upload same image on two locations same time with move_uploaded_file() function like this

  $fpath="../p/e/".$prop_fac1;
  $error = move_uploaded_file($tmp_name, $fpath);

  $fpath1="../p/t/".$prop_fac1;
  $error1 = move_uploaded_file($tmp_name, $fpath1);

the problem is, first part works mean it upload files to ../p/e but not copy file to second location...

the problem is, first part works mean it upload files to ../p/e but not copy file to second location...

Works as designed. The file is moved , not copied. Use copy() for the second command, using the target path from the first one.

 $error1 = copy($fpath, $fpath1);

That would be because it's MOVE_uploaded_file, not COPY_uploaded_file. What you need to do is:

move_uploaded_file($tmp_name, $fpath);
copy($fpath, $fpath1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM