Jump to content

Clinton Skakun

Starter
  • Posts

    1
  • Joined

  • Last visited

Clinton Skakun's Achievements

Starter

Starter (1/6)

0

Reputation

  1. I'm getting a strange error when uploading multiple image fields at once. This happens randomly so I'm not sure what the hell is going on. I have two image fields in my form (in the frontend) called "cara" and "ife". I noticed some images would suddenly not show in user profiles (where I'm uploading images) I get "could not move file" errors but the image still gets uploaded and other times there's no error and the image is not uploaded. $uid = $input->urlSegment(2); $u = $users->get("id=$uid"); if(isset($_FILES["ife"]["tmp_name"])) { $tempDir = wire()->files->tempDir('userUploadsIfe')->get(); $wu = new WireUpload('ife'); $uploaded = $wu // same as form field name ->setValidExtensions(['gif', 'png', 'jpg', 'jpeg']) ->setMaxFiles(2) // remove this to allow multiple files ->setMaxFileSize(41943040)// 40MB ->setDestinationPath($tempDir) ->execute(); if(count($wu->getErrors())) { $errors[] = $wu->getErrors()[0]; } else { $u->ife->removeAll(); } foreach($uploaded as $file) { $filePath = $tempDir . $file; $u->ife->add($filePath); } } if(isset($_FILES["cara"]["tmp_name"])) { $tempDir = wire()->files->tempDir('userUploadsCara')->get(); $wu2 = new WireUpload('ife'); $uploaded = $wu2 // same as form field name ->setValidExtensions(['gif', 'png', 'jpg', 'jpeg']) ->setMaxFiles(1) // remove this to allow multiple files ->setMaxFileSize(41943040)// 40MB ->setDestinationPath($tempDir) ->execute(); if(count($wu2->getErrors())) { $errors[] = $wu2->getErrors()[0]; } else { $u->cara->removeAll(); } foreach($uploaded as $file) { $filePath = $tempDir . $file; $u->cara->add($filePath); } } $u->save();
×
×
  • Create New...