Мой скрипт загрузки работает во всех браузерах, включая IE. Но не работает в firefox. У меня есть три файла. 1> Содержит сценарий загрузки и переменные. 2> Является файлом newuploadify.php, который запускает сеансы и присваивает переменным сеанса некоторые значения. 3> Является ли для вставки данных в базу данных на основе сеансов.
Это прекрасно работает во всех браузерах, кроме хрома (не Chrome) и Firefox.
Почему-то сеанс не передается из второго файла в третий файл в Firefox.
Мои скрипты
1> `
<?php if (!isset($_SESSION)) {
session_start();
}
?>
<html>
<head>
<style>
<style type="text/css">
.uploadify-button {
background-color: transparent;
border: none;
padding: 0;
}
.uploadify:hover .uploadify-button {
background-color: transparent;
}
</style>
</style>
<script type="text/javascript" src="uploadify/jquery.uploadify-3.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="uploadify/uploadify.css" />
<script>
var $j = jQuery.noConflict();
$j(document).ready(function(){
$j("#photocancelbtn").hide();
$j("#photouploadstartbtn").hide();
$j("#filein").hide();
$j("#filein").fadeIn(8000);
$j(function() {
$j('#file_upload').uploadify({
auto : false,
'swf' : 'uploadify/uploadify.swf',
'uploader' : 'newuploadify.php',
// Put your options here
'queueSizeLimit' : 1,
'checkExisting' : '/uploadify/check-exists.php',
'multi' : false,
'buttonText' : 'Add Photo',
'fileTypeDesc' : 'Image Files',
'fileTypeExts' : '*.gif; *.jpg; *.png; *.JPG',
'fileSizeLimit' : '5MB',
'onClearQueue' : function(queueItemCount) {
$j("#photocancelbtn").hide();
$j("#photouploadstartbtn").hide();
},
'onSelect' : function(file) {
$j("#photocancelbtn").show();
$j("#photouploadstartbtn").show();
},
'onUploadSuccess' : function(file, data, response) {
$j("#photocancelbtn").hide();
$j("#photouploadstartbtn").hide();
changeBtnText();
}
}); /* closing uploadify line*/
}); /* closing funciton line*/
}); /*closing document ready function*/
function changeBtnText() {
$j('#file_upload').uploadify('settings','buttonText','Change Photo');
}
function restoreBtnText() {
$j('#file_upload').uploadify('settings','buttonText','Add Photo');
}
</script>
</head>
<body>
<table>
<tr>
<td id="filein">
<input type="file" name="file_upload" id="file_upload" />
</td>
<td id="btns">
<a id="photouploadstartbtn" href="javascript:$j('#file_upload').uploadify('upload')">Start Upload</a><br>
<a id="photocancelbtn" href="javascript:$j('#file_upload').uploadify('cancel','*');">Remove photo</a>
</td>
</tr>
</table>
</body>
</html>
`
Также пробовал передавать данные через scriptData в приведенном выше коде, но результат тот же.
2>
`
<?php if (!isset($_SESSION)) {
session_start();
}
require('connection.php');
$targetFolder = '/images/'; // Relative to the root
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$randomid=uniqid();
$targetFile = rtrim($targetPath,'/') . '/'.$randomid.$_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png','JPG','PNG'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
$fp = fopen($tempFile, 'r');
$data = fread($fp, filesize($tempFile));
$data = addslashes($data);
fclose($fp);
move_uploaded_file($tempFile,$targetFile);
$_SESSION['photopath'] = $randomid.$_FILES['Filedata']['name']; //Just storing the file name for the path.
$_SESSION['photocheck']='Y';
/*The above sessions are setting but are not being passed to the third file.
error_log($_SESSION['photopath']);
error_log($_SESSION['photocheck']);
error_log(session_id());
} else {
echo 'Invalid file type.';
}
}
?>
`
3>
`
#Getting if photo is added.
if(isset($_SESSION['photocheck'])){
$photocheck=$_SESSION['photocheck'];
error_log('Photocheck=');
error_log($photocheck);
unset($_SESSION['photocheck']);
}
if(isset($_SESSION['photopath'])){
//$photo=$_SESSION['photo'];#Encoding string as image. For using mysqli no need to do this step.just bind param as string.
$photopath=$_SESSION['photopath'];
error_log('Photopath=');
error_log($photopath);
unset($_SESSION['photopath']);
}
#Inserting
if($photocheck=='Y'){
error_log('Entered into insert q');
}
else{
error_log('Did not enter !!');
}
`
Я получаю сообщение «Не входил при работе с firefox» и «Ввод вставки q» при использовании других браузеров. Пожалуйста помогите .