public function filesdropzoneAction() { $storeFolder = $_SERVER['DOCUMENT_ROOT'] . '/files/clientes'; $request = $this->getRequest(); if ($request->isPost()) { $post_data = $request->getPost(); $files = $request->getFiles(); $id = $post_data['id']; $tempFile = $files['file']['tmp_name']; $targetFile = $storeFolder . '/' . $id . '/' . $_FILES['file']['name']; if (!file_exists($storeFolder . '/' . $id)) { mkdir($storeFolder . '/' . $id, 0777, true); } move_uploaded_file($tempFile, $targetFile); //Guardamos en nuestra base de datos $cliente_archivo = new \Clientearchivo(); $cliente_archivo->setIdcliente($id); $cliente_archivo->setClientearchivoArchivo('/files/clientes' . '/' . $id . '/' . $_FILES['file']['name']); $cliente_archivo->setClientearchivoSize($_FILES['file']['size']); $cliente_archivo->save(); return $this->getResponse()->setContent(json_encode(array('response' => true, 'id' => $cliente_archivo->getIdclientearchivo()))); } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Clientearchivo $obj A Clientearchivo object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getIdclientearchivo(); } // if key === null ClientearchivoPeer::$instances[$key] = $obj; } }
/** * @param Clientearchivo $clientearchivo The clientearchivo object to add. */ protected function doAddClientearchivo($clientearchivo) { $this->collClientearchivos[] = $clientearchivo; $clientearchivo->setCliente($this); }
/** * Filter the query by a related Clientearchivo object * * @param Clientearchivo|PropelObjectCollection $clientearchivo the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ClienteQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByClientearchivo($clientearchivo, $comparison = null) { if ($clientearchivo instanceof Clientearchivo) { return $this->addUsingAlias(ClientePeer::IDCLIENTE, $clientearchivo->getIdcliente(), $comparison); } elseif ($clientearchivo instanceof PropelObjectCollection) { return $this->useClientearchivoQuery()->filterByPrimaryKeys($clientearchivo->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByClientearchivo() only accepts arguments of type Clientearchivo or PropelCollection'); } }
/** * Exclude object from result * * @param Clientearchivo $clientearchivo Object to remove from the list of results * * @return ClientearchivoQuery The current query, for fluid interface */ public function prune($clientearchivo = null) { if ($clientearchivo) { $this->addUsingAlias(ClientearchivoPeer::IDCLIENTEARCHIVO, $clientearchivo->getIdclientearchivo(), Criteria::NOT_EQUAL); } return $this; }