php변수를 스크립트로 보내기 질문입니다.
본문
upload_pop.php 에서 읽어온 $BUILD_ID와 $BUILD_SEQ 를
upload.php 에서 받아서 폴더를 만들때 $BUILD_ID와 $BUILD_SEQ 를 붙여서 만들고 싶습니다.
변수를 upload.php로 보내야 하는데 어떻게 보내야 할까요???
폼을 보내는 upload_pop.php
<?php
include_once('./_common.php');
$BUILD_ID = $_POST['build_id'];
$BUILD_SEQ = $_POST['build_seq'];
?>
<html>
<head>
<link href="https://rawgithub.com/hayageek/jquery-upload-file/master/css/uploadfile.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://rawgithub.com/hayageek/jquery-upload-file/master/js/jquery.uploadfile.min.js"></script>
</head>
<body>
<div id="fileuploader">Upload</div>
<script>
$(document).ready(function() {
$("#fileuploader").uploadFile({
url:"<?php echo G5_PLUGIN_URL ?>/upload/upload.php",
fileName:"myfile"
});
});
</script>
</body>
</html>
폼을 받는 upload.php
<?php
include_once('./_common.php');
global $g5, $config;
//$output_dir = G5_DATA_URL.'/build_file/'.$BUILD_ID.'/'.$BUILD_SEQ.'/';
//$output_dir = "uploadsupup/";
$output_dir = G5_DATA_PATH.'/build_file/'.$BUILD_ID.'/UPUPUP/';
if(is_dir($output_dir)){
echo "O";
}else{
echo "X";
@mkdir($output_dir, 0777);
}
if(isset($_FILES["myfile"]))
{
$ret = array();
// This is for custom errors;
/* $custom_error= array();
$custom_error['jquery-upload-file-error']="File already exists";
echo json_encode($custom_error);
die();
*/
$error =$_FILES["myfile"]["error"];
//You need to handle both cases
//If Any browser does not support serializing of multiple files using FormData()
if(!is_array($_FILES["myfile"]["name"])) //single file
{
$fileName = $_FILES["myfile"]["name"];
move_uploaded_file($_FILES["myfile"]["tmp_name"],$output_dir.$fileName);
$ret[]= $fileName;
}
else //Multiple files, file[]
{
$fileCount = count($_FILES["myfile"]["name"]);
for($i=0; $i < $fileCount; $i++)
{
$fileName = $_FILES["myfile"]["name"][$i];
move_uploaded_file($_FILES["myfile"]["tmp_name"][$i],$output_dir.$fileName);
$ret[]= $fileName;
}
}
echo json_encode($ret);
}
?>
!-->!-->
답변을 작성하시기 전에 로그인 해주세요.