asked on
ASKER
ASKER
$("#excel #buttonUpload").live("click", function(event){
// send nothing (or some cookies & donuts) to upl3.php
$.ajax({ type: 'POST', url: "upl3.php" });
// hide the modal
fx.boxout(event);
// set the value of a form?
$("#form").val(5);
// submit the form and reload the page
$("#ctrform").submit();
});
ASKER
ASKER
$.ajax({
type: 'POST',
url: "upl3.php"
});
ASKER
$("#excel #buttonUpload").live(
"click", function(event){
$("#excel").submit();
fx.boxout(event);
$("#form").val(5);
$("#ctrform").submit();
}
);
upl2:
<form name="excel" id="excel" action="upl3.php"
method="POST" enctype="multipart/form-data"
target="upload_target">
<table cellpadding="0" cellspacing="0" class="tableForm">
<thead>
<tr>
<th>Please select a file and click Upload button</th>
</tr>
</thead>
<tbody>
<tr>
<td><input id="fileToUpload" type="file" size="25" name="fileToUpload" class="input"></td> </tr>
</tbody>
<tfoot>
<tr>
<td><button id="buttonUpload" class="button">Upload</button></td>
</tr>
</tfoot>
</table>
</form>
<iframe id="upload_target" name="upload_target" src="#" style="display:none"></iframe>
FORM_MARKUP;
$("#excel #buttonUpload").live(
"click", function(event){
$("#excel").submit();
fx.boxout(event);
$("#form").val(5);
$("#ctrform").submit();
}
);
by :$("#excel #buttonUpload").live("click", function(event){
//$.ajax({ type: 'POST', url: "upl3.php" });
$("#upload_target").load(function() {
fx.boxout(event);
})
$("#form").val(5);
//$("#ctrform").submit();
});
ASKER
<?php
session_start ();
switch ($_POST ['form']) {
case '1' :
break;
case '4':
break;
case '2':
break; // bulk load
case '5':
echo 'excel';
var_dump($_FILES);
break;
}
?>
<!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" />
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/themes/base/jquery-ui.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style TYPE="text/css">
a.button {
background-color: #aaa;
}
#page_bg {
padding: 0;
background-color: #A0B0B8;
}
</style>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js">
</script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#excel").bind("click", function(event){
event.preventDefault();
$.ajax({
type: "POST",
url: "upl2.php",
data: "action=excel",
success: function(data) {
var form = $(data).hide(),
modal = fx.initModal();
fx.boxin(null,modal);
form
.appendTo(modal)
.addClass("savtxta")
.fadeIn("slow");
},
error: function(msg){
modal.append(msg);
alert("error");
}
});
modal = fx.initModal();
});
$("#excel #buttonUpload").live(
"click", function(event){
$("#upload_target").load(function() {
// fx.boxout(event);
});
$("#form").val(5);
//$("#ctrform").submit();
});
var fx = {
// Checks for a modal window and returns it, or
// else creates a new one and returns that
"initModal" : function() {
// If no elements are matched, the length
// property will return 0
if ( $(".modal-window").length==0 )
{
// Creates a div, adds a class, and
// appends it to the body tag
return $("<div>")
.addClass("modal-window")
.appendTo("body");
}
else
{
// Returns the modal window if one
// already exists in the DOM
return $(".modal-window");
}
},
"boxin": function(data,modal) {
$("<div>")
.hide()
.addClass("modal-overlay")
.click(function(event) {
fx.boxout(event);
}).appendTo("body");
modal
.hide()
.append(data)
.appendTo("body");
$(".modal-window,.modal-overlay")
.fadeIn("slow");
},
"boxout": function(event) {
if (event!=undefined)
{
event.preventDefault();
}
$("a").removeClass("active");
$(".modal-window, .modal-overlay")
.fadeOut("slow",function(){
// $(this).remove();
}
);
}
};
});
</script>
</head>
<body id="page_bg">
<div id="wrapper">
<form id="ctrform" name="ctrform" method='post'>
<input type="hidden" name="form" id="form">
<div > <a id="excel" class="button" href="#"><span> Excel </span></a> </div>
</form>
</div>
</body>
</html>
<?php
session_start();
// Displays popups through modal windows
if ((isset($_POST['action'])))
{
$act = trim(($_POST['action']));
switch($act)
{
case 'excel':
$formmrk =<<<FORM_MARKUP
<form name="excel" id="excel" action="upl3.php"
method="POST" enctype="multipart/form-data"
target="upload_target">
<table cellpadding="0" cellspacing="0" class="tableForm">
<thead>
<tr>
<th>Please select a file and click Upload button</th>
</tr>
</thead>
<tbody>
<tr>
<td><input id="fileToUpload" type="file" size="25" name="fileToUpload" class="input"></td> </tr>
</tbody>
<tfoot>
<tr>
<td><button id="buttonUpload" class="button">Upload</button></td>
</tr>
</tfoot>
</table>
</form>
<iframe id="upload_target" name="upload_target" src="#" style="display:none"></iframe>
FORM_MARKUP;
echo $formmrk;
break;
}
}
?>
<?php
session_start();
$target="/tmp/";
ini_set ("display_errors", "1");
error_reporting(E_ALL);
$fileElementName = 'fileToUpload';
if(!empty($_FILES[$fileElementName]['error']))
{
switch($_FILES[$fileElementName]['error'])
{
case '1':
$error = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
break;
case '2':
$error = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
break;
case '3':
$error = 'The uploaded file was only partially uploaded';
break;
case '4':
$error = 'No file was uploaded.';
break;
case '6':
$error = 'Missing a temporary folder';
break;
case '7':
$error = 'Failed to write file to disk';
break;
case '8':
$error = 'File upload stopped by extension';
break;
case '999':
default:
$error = 'No error code avaiable';
}
}elseif(empty($_FILES['fileToUpload']['tmp_name']) || $_FILES['fileToUpload']['tmp_name'] == 'none')
{
$error = 'No file was uploaded..';
}else
{
$msg .= " File Name: " . $_FILES['fileToUpload']['name'] . ", ";
$msg .= " File Size: " . @filesize($_FILES['fileToUpload']['tmp_name']);
//for security reason, we force to remove all uploaded file
move_uploaded_file($_FILES['fileToUpload']['tmp_name'],$target.$_FILES['fileToUpload']['name']);
@unlink($_FILES['fileToUpload']);
}
echo "{";
echo "error: '" . $error . "',\n";
echo "msg: '" . $msg . "'\n";
echo "}";
?>
ASKER
on line 46
{
Notice: Undefined variable: error in C:\Apache22\htdocs\upl3-2.php on line 58
error: '', msg: ' File Name: Clipboard06.jpg, File Size: 125733' }
ASKER
ASKER
ASKER
$("#excel").ajaxForm({
"success": function(data) {
fx.boxout(event);
}
});
ASKER
ASKER
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY
<form name="excel" id="excel" action=""
method="POST" enctype="multipart/form-da
target="upload_target">