It looks like you're new here. If you want to get involved, click one of these buttons!
/**
* Long description for file uploadify-custom.js
* Copyright 2011, TuxaneSoft,France (http://www.tuxane.com/)
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
* @version 0.5
* @modifiedby $jw$
* @lastmodified 16.02.2011
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
$(document).ready(function() {
$('#file_upload').uploadify({
'uploader' : '/uploadify/uploadify.swf',
'script' : '/uploadify/uploadify.php',
'cancelImg' : '/uploadify/cancel.png',
'folder' : '/uploads/upload_banner_image',
'auto' : true,
'multi' : false,
'fileDesc' : 'Images',
'onComplete': function(event, queueID, fileObj, response, data){
var form = document.forms['BannerAddForm'];
var i = 0;
var el = document.createElement("input");
el.type = "hidden";
el.name = "data[Banner][image]";
el.id = "BannerImage";
el.value = fileObj.name;
form.appendChild(el);
},
'onAllComplete': function(event,data) { document.getElementById('BannerAddForm').submit();},
});
});
<?php
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
echo '0'; // Required to trigger onComplete function on Mac OSX (same for linux and windows as it seems)
}
else { // Required to trigger onComplete function on Mac OSX (same for linux and windows as it seems)
echo '1';
}
?>
<input id="file_upload" name="file_upload" type="file" /> <a href="javascript:$('#file_upload').uploadifyUpload();"><img id="withupload" src="img/submit.gif" /></a>
/**
* Long description for file uploadify-custom.js
* Copyright 2011, TuxaneSoft,France (http://www.tuxane.com/)
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
* @version 0.6
* @modifiedby $jw$
* @lastmodified 18.02.2011
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
$(document).ready(function() {
var i = 0;
$('#file_upload').uploadify({
'uploader' : '/backend/uploadify/uploadify.swf',
'script' : '/backend/uploadify/uploadify.php',
'cancelImg' : '/backend/uploadify/cancel.png',
'folder' : '/uploads',
'auto' : false,
'multi' : true,
'fileDesc' : 'Images',
'onComplete': function(event, queueID, fileObj, response, data){
var form = document.forms['ImageAddForm'];
var el = document.createElement("input");
el.type = "hidden";
el.name = "data[Image][name]["+i+"]";
el.id = "ImageFile["+i+"]";
el.value = fileObj.name;
form.appendChild(el);
i++;
},
});
});
<input id="FormImageFile[1]" type="hidden" name="data[Image][name][1]" value="file1.jpg">
$(document).ready(function() {
$("#fileUploadstyle").fileUpload({
'uploader': '/uploadify/uploader.swf',
'cancelImg': '/uploadify/cancel.png',
'script': '/photo/enregistrer_ajout.php',
'folder': '/upload/<?php echo $nomVille?>',
'buttonImg': '/uploadify/images/browseBtn.png',
'multi': true,
'displayData': 'speed',
'width': 120, //80
'height': 24,
'rollover': true,
'fileDesc': 'Fichier image : JPG (*.jpg), JPEG(*.jpeg)',
'fileExt': '*.jpg;*.jpeg;',
'scriptData': {'idVille':'<?php echo $idVille?>'},
'onComplete': function(event, queueID, fileObj, response, data){
var form = document.forms['ajout'];
var el = document.createElement("input");
el.type = "hidden";
el.name = "fichier";
el.id = "ImageFile["+i+"]";
el.value = fileObj.name;
form.appendChild(el);
i++;
}
})
<div id="fileUploadstyle">Vous avez un problème avec Javascript</div>
<a href="javascript:$('#fileUploadstyle').fileUploadStart()">Télécharger</a> | <a href="javascript:$('#fileUploadstyle').fileUploadClearQueue()">Vider la liste</a>
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'].$_GET['folder'].'/';
$targetFile = str_replace('//','/',$targetPath).$_FILES['Filedata']['name'];
// Creation du dossier de destination
mkdir(str_replace('//','/',$targetPath), 0755, true);
move_uploaded_file($tempFile, $targetFile);
echo 0;
} else {
echo '1';
}
<script type="text/javascript">
$(document).ready(function() {
$('#sub_form').hide();
$('#file_upload').uploadify({
'uploader' : '/uploadify/uploadify.swf',
'script' : '/uploadify/uploadify.php',
'cancelImg' : '/uploadify/cancel.png',
'folder' : '/gfx/upload',
'multi' : true,
'auto' : false,
'queueID' : 'custom-queue',
'queueSizeLimit' : 3,
'simUploadLimit' : 3,
'removeCompleted': false,
'fileExt' : '*.jpg;*.gif;*.png',
'fileDesc' : 'Image Files (.JPG, .GIF, .PNG)',
'onSelectOnce' : function(event,data) {
$('#status-message').text(data.filesSelected + ' files have been added to the queue.');
},
'onComplete': function(event, queueID, fileObj, response, data){
var form = document.forms['form1'];
//var i = 0;
var el = document.createElement("input");
el.type = "hidden";
el.name = "data[Image][name]["+i+"]";
el.id = "ImageFile["+i+"]";
el.value = fileObj.name;
form.appendChild(el);
i++;
},
'onAllComplete' : function(event,data) {
$('#status-message').text(data.filesUploaded + ' files uploaded, ' + data.errors + ' errors.');
$('#sub_form').show();
}
});
});
</script>
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
// $fileTypes = str_replace('*.','',$_REQUEST['fileext']);
// $fileTypes = str_replace(';','|',$fileTypes);
// $typesArray = split('\|',$fileTypes);
$fileParts = pathinfo($_FILES['Filedata']['name']);
$fileExt = '.'.$fileParts['extension'];
// if (in_array($fileParts['extension'],$typesArray)) {
// Uncomment the following line if you want to make the directory if it doesn't exist
// mkdir(str_replace('//','/',$targetPath), 0755, true);
//below code gives each picture a unique name
$tfn = 0;
while(is_file($targetFile)) {
$targetFile = str_ireplace($fileExt, '', $targetFile);
$targetFile = str_ireplace('['.$tfn.']', '', $targetFile);
$tfn++;
$targetFile = $targetFile.'['.$tfn.']'.$fileExt;
}
move_uploaded_file($tempFile,$targetFile);
echo '0';
//echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
} else {
echo '1';
}
?>
The images get uploaded, but the hidden fields do not appear to be added to my form (form1). Any thoughts? Thanks!
$(document).ready(function() {
var i = 0;
$('#file_upload').uploadify({
'uploader' : '/uploadify/uploadify.swf',
'script' : '/uploadify/uploadify2.php',
'cancelImg' : '/uploadify/cancel.png',
'folder' : '/uploads',
'auto' : false,
'multi' : true,
'fileDesc' : 'Images',
'onComplete': function(event, queueID, fileObj, response, data){
var form = document.forms['ImageAddForm'];
var el = document.createElement("input");
el.type = "hidden";
el.name = "datos"+i;
el.id = "datos"+i;
el.value = fileObj.name;
form.appendChild(el);
i++;
},
});
});
</script>
</head>
<body>
<form id="ImageAddForm" name="ImageAddForm">
<input id="file_upload" name="file_upload" type="file" />
<a href="javascript:$('#file_upload').uploadifyUpload();">Up</a>
</form>...
$id_usuario = $_REQUEST['datos0']; //For example
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
echo '0';
$resultado = $conexion->modifica("INSERT INTO foto (id_user, url_foto) VALUES('$id_usuario','$newFileName')", $nombre_bd);
echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
} else {
echo '1';
}