Buenas a todos, tengo una duda sobre un código de un multi uploader el cual va por javascript.
Hay dos archivos, mas las carpetas que trae con los .JS
index.php
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Multiple files upload in PHP with using Uploadify!</title>
<!-- CSS -->
<link rel="stylesheet" href="uploadifyit/uploadify.css" type="text/css" />
<!-- Javascript -->
<script type="text/javascript" src="uploadifyit/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="uploadifyit/swfobject.js"></script>
<script type="text/javascript" src="uploadifyit/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
//alert('I am ready to use uploadify!');
$("#file_upload").uploadify({
'uploader': 'uploadifyit/uploadify.swf',
'script': 'uploadifyit/uploadify.php',
'cancelImg': 'uploadifyit/cancel.png',
'folder': 'uploads',
'auto': false, // use for auto upload
'multi': true,
'queueSizeLimit': 4,
'onQueueFull': function(event, queueSizeLimit) {
alert("Please don't put anymore files in me! You can upload " + queueSizeLimit + " files at once");
return false;
},
'onComplete': function(event, ID, fileObj, response, data) {
// you can use here jQuery AJAX method to send info at server-side.
$.post("insert.php", { name: fileObj.name }, function(info) {
//alert(info); // alert UPLOADED FILE NAME
});
}
});
});
</script>
</head>
<body>
<form id="form1" name="form1" action="">
<input type="file" id="file_upload" name="file_upload" /><br />
<a href="javascript:$('#file_upload').uploadifyUpload();">Upload File</a>
</form>
</body>
</html>
Archivo insert.php
Código:
<?php
// connect database
$dbc = mysql_connect("localhost", "root", "****");
// select database
mysql_select_db("galeria", $dbc);
if(isset($_POST)) {
//echo $_POST['name'];
$fileName = $_POST['name'];
$time = time();
$reportaje = $_POST[reportaje];
mysql_query("INSERT INTO uploadify(filename, reportaje, filedate) VALUES('$fileName','$reportaje', '$time')");
$inserted_id = mysql_insert_id($dbc);
if($inserted_id > 0) { // if success
echo "uploaded file: " . $fileName;
}
}
?>
El caso que index.php no cambia a inset.php, simplemente insert.php actua y listo. Entonces no consigo enviar un post.
¿Como debería hacerlo? :S