Jump to content

WireUpload not working correctly?


Tom.
 Share

Recommended Posts

I have a script that I would like to upload and make sure the files keep it's file name. This is a multi-image image field. 

Just using $p->images->add($_FILES['file']['tmp_name']) works. However this doesn't: 

if(count($_FILES['file']) != 0) {
  $p->images->removeAll();

  $u = new WireUpload('file');
  $u->setDestinationPath($p->images->path);
  foreach($u->execute() as $filename) $p->images->add($filename);
}

if(!$error) $p->save();

There is no error given, however non of the images are added? What am I missing here?

 

Edit:

print_r($u);
print_r($u->execute());

Both return an empty array. I'm guessing WireUpload('file') doesn't use $_FILES and there for can not be used with DropZone? 

Edit2: 
WireUpload does use $_FILES. There is some sort of bug happening here with using Ajax and WireUpload.

Link to comment
Share on other sites

1 hour ago, Tom. said:

Edit:


print_r($u);
print_r($u->execute());
1 hour ago, Tom. said:

What am I missing here?

You are obviously missing TracyDebugger ?? SCNR, but joke aside, tracy does also help you a lot on ajax debugging. It has fl() = firelog and bd() = bardump that can help a lot to see what's going on!

A quick guess: If you are using custom AJAX scripts it might be the case that the headers are not set correctly so that PW recognizes it as $config->ajax == true. Maybe that's not at all helpful, not sure, but in a hurry ?

 

  • Like 2
Link to comment
Share on other sites

38 minutes ago, bernhard said:

You are obviously missing TracyDebugger ?? SCNR, but joke aside, tracy does also help you a lot on ajax debugging. It has fl() = firelog and bd() = bardump that can help a lot to see what's going on!

A quick guess: If you are using custom AJAX scripts it might be the case that the headers are not set correctly so that PW recognizes it as $config->ajax == true. Maybe that's not at all helpful, not sure, but in a hurry ?

 

I believe it's an issue with DropZone. I've decided to do the following:

		if(count($_FILES['file']) == 0) {
			$error = "Please upload your entries.";
		} else {
			$count = count($_FILES['file']['name']);

			for($i = 0; $i < $count; $i++) {
				$file = $p->images->path . $sanitizer->pageName($_FILES['file']['name'][$i]);

				if(move_uploaded_file($_FILES['file']['tmp_name'][$i], $file)) {
					$p->images->add($file);
				}
			}
		}

		if(!$error) $p->save();

Which works a charm ? Thanks @bernhard

  • Like 1
Link to comment
Share on other sites

  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...