Jump to content
Programar

Multiupload

Recommended Posts

Programar

Na página fotos.php a negrito está o <form> que é onde manda as fotos selecionadas para a upload.php que faz o upload para a bd. O que não estou a conseguir passar é o id_stock.

Se alguém me poder ajudar agradeço desde já.

fotos.php

<?php include "../liga/liga.php";
session_start(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Rodricar</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript" src="js/multiUpload.js"></script>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">

$(document).ready(function(){

$("select[name=marca]").change(function(){
$("select[name=modelo]").html('<option value="0">Carregando...</option>');

$.post("modelos.php",
{marca:$(this).val()},
function(valor){
$("select[name=modelo]").html(valor);
}
)

})
})

</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- CSS -->
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,400">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Droid+Sans">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lobster">
<link rel="stylesheet" href="../assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="../assets/prettyPhoto/css/prettyPhoto.css">
<link rel="stylesheet" href=../"assets/css/flexslider.css">
<link rel="stylesheet" href="../assets/css/font-awesome.css">
<link rel="stylesheet" href="../assets/css/style.css">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Favicon and touch icons -->
<link rel="shortcut icon" href="../assets/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
</head>
<style type="text/css">
@import "css/multiUpload.css";
</style>
<body>
<!-- Header -->
<div class="container">
<div class="header row">
<div class="span12">
<div class="navbar">
<div class="navbar-inner">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<h1>
<a class="brand" href="index.php">Andia - a super cool design agency...</a>
</h1>
<div class="nav-collapse collapse">
<?php include "menu.php"; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Page Title -->
<div class="page-title">
<div class="container">
<div class="row">
<div class="span12">

<h2 style="padding-left:15px;">Stock /</h2>
<p>Viaturas de excelência...</p> <h5 style="float:right;">Bem-vindo <?php echo $_SESSION['nome']; ?> - <a href="logout.php" style="margin-right:37px;">Logout</a></h5>
</div>
</div>
</div>
</div>
<!-- Portfolio -->
<div class="portfolio portfolio-page container">
<div class="row">
<div class="services-full-width-text span12">
<h4 style="padding-left:27px;">Inserir Viatura</h4>
<p><hr style="width:1110px; margin-left:27px; border:1px solid #9d426b">
</div></div></div>

<div class="contact-us container" style="border:0px solid red; margin-top:-50px; padding-left:15px;">
<div class="row" style="margin-top:-40px;">
<div class="contact-form span7">









[b] <form method="post" action="#" style="padding-left:20px;">

<?php
$id_stock=$_GET['id_stock'];
?>
<script type="text/javascript">
var uploader = new multiUpload('uploader', 'uploader_files', {
swf: 'swf/multiUpload.swf', //
script: 'upload.php',
expressInstall: 'swf/expressInstall.swf',
multi: true
});
</script>[/b]
[b]<div id="uploader"></div>
<div id="uploader_files" style="border:1px solid #CCC; width:564px;"></div>
<a href="javascript:uploader.startUpload();"><div class="olaa" style=" width:93px; padding:5px; border:1px solid #666666; background:#e3dfd8; margin-top:5px; color:#000;"><b>INICIAR UPLOAD</b></div></a>
<br>
<br>

</form>[/b]









</div></div></div>

<!-- Footer -->
<footer>
<div class="container">
<div class="row">
<div class="widget span3">
<h4>Sobre Nós</h4>
<p>A Rodricar cria soluções adequadas para o seu dia a dia com o objetivo de lhe realizar sonhos sem colocar em causa a sua realidade...</p>
<p><a href="sobre_nos.php">Saber Mais...</a></p>
</div>

<div class="widget span3">
<h4>Serviços</h4>
<p><i class="icon-map-marker"></i> Abervamentos Auto</p>
<p><i class="icon-phone"></i> Inspeção Periodica</p>
<p><i class="icon-user"></i> Revisões e Oficina</p>
<p><i class="icon-user"></i> Viatura Substituição</p>
<p><a href="servicos.php">Saber Mais...</a></p>
</div>
<div class="widget span3">
<h4>Financiamento</h4>
<p>Uma nova realidade que tornará possíveis todos os seus sonhos com uma taxa de juro apartir de 7,8%.</p>
<p><a href="financiamento.php">Saber Mais...</a></p>
<!--<div class="show-tweets"></div>-->
</div>
<div class="widget span3">
<h4>Contatos</h4>
<p><i class="icon-map-marker"></i> Morada: Rua da empresa, Ribeirão, Portugal</p>
<p><i class="icon-phone"></i> Telefone: 252 252 252</p>
<p><i class="icon-user"></i> Skype: rodricar_stand</p>
<p><i class="icon-envelope-alt"></i> Email: <a href="">contato@rodricar.com</a></p>
</div>
</div>
<div class="footer-border"></div>
<div class="row">
<div class="copyright span4">
<p>Copyright 2013 Rodricar - All rights reserved.</a>.</p>
</div>
<div class="social span8">
<a class="facebook" href=""></a>
<a class="dribbble" href=""></a>
<a class="twitter" href=""></a>
<a class="pinterest" href=""></a>
</div>
</div>
</div>
</footer>
<!-- Javascript -->
<script src="assets/js/jquery-1.8.2.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/jquery.flexslider.js"></script>
<script src="assets/js/jquery.tweet.js"></script>
<script src="assets/js/jflickrfeed.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="assets/js/jquery.ui.map.min.js"></script>
<script src="assets/js/jquery.quicksand.js"></script>
<script src="assets/prettyPhoto/js/jquery.prettyPhoto.js"></script>
<script src="assets/js/scripts.js"></script>
</body>
</html>

upload.php

<?php
/**
* Conexão Mysql
*/
$conn = mysql_connect('localhost', 'root', '');
$db = mysql_select_db('rodricar');
session_start();
$file = $_FILES['Filedata'];
$album = (int) $_POST['id'];
$filename = $file['name'];
$id_stock = $_GET['id_stock'];
$query = "INSERT INTO fotos (id, foto, id_stock) VALUES ('$id', '$filename','".$_GET['id_stock']."')";
mysql_query($query);
$path = $file['tmp_name'];
$new_path = "imagens/".$file['name'];
move_uploaded_file($path, $new_path);
// Vamos usar a biblioteca WideImage para o redimensionamento das imagens
require("lib/WideImage/WideImage.php");
// Carrega a imagem enviada
$original = WideImage::load($new_path);
// Redimensiona a imagem original para 1024x768 caso ela seja maior que isto e salva
$original->resize(1024, 768, 'inside', 'down')->saveToFile($new_path, null, 90);
// Cria a miniatura
$ext = end(explode(".", $new_path)); // Pega a extensão do arquivo
$thumb = str_replace(".$ext", "_thumb.$ext", $new_path); // Substitui a extensão
$original->resize(100, 75, 'inside', 'down')->saveToFile($thumb, null, 90); // Redimensiona e salva
echo mysql_insert_id(); // Retorna o id da foto
?>

Edited by thoga31
GeSHi

Share this post


Link to post
Share on other sites
HappyHippyHippo

que multiupload estás a usar para fazer o upload dos ficheiros ?


IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites
HappyHippyHippo

se leres o exemplo veràs como enviar mais informação do que ficheiros


IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites

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

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.