Skip to content

Instantly share code, notes, and snippets.

@klederson
Created June 10, 2009 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klederson/127226 to your computer and use it in GitHub Desktop.
Save klederson/127226 to your computer and use it in GitHub Desktop.
<?php
$fileName = $pictures['name'][$index];
$tmpName = $pictures['tmp_name'][$index];
$fileSize =$pictures['size'][$index];
$fileType = $pictures['type'][$index];
//Abrindo o arquivo para leitura e conversão em STRING
$fp = fopen($tmpName, 'r'); //$tmpName é o nome e caminho completos para o arquivo em disco
//Lendo o arquivo carregado para uma STRING
$content = fread($fp, filesize($tmpName));
//Fechando a conexao com o arquivo
fclose($fp);
//Adicionando slashes para segurança
if(!get_magic_quotes_gpc()) {
$fileName = addslashes($fileName);
}
Lumine::import('OrderProducts');
$orderProductId = $_REQUEST['hidden_id'][$index];
$orderProduct = new OrderProducts();
$orderProduct->get($orderProductId);
//Setando a variavel ( banco ) que irá receber o arquivo
$orderProduct->content = $content;
$orderProduct->content_name = $fileName;
$orderProduct->save();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment