<?php
/*
Permet l'upload sur le serveur d'un fichier.
la focntion fait necessaireemnt appel a la libarrie des xmedia
arguement:
form = aray (id = name + id form
	js = action js ou report supplementaire
	vars = action complementaire sur appel_fct via faux tableau
	extract_zip = (boolean) poru extraire le zip
	new_folder_for_zip = (boolean) poru creer un repertoire dans lesquel seront placé le sfichier du rep
	force_folder >> defaut:IMG sinon au choix, absolu a partir de la racine
		)
*/
function upload($form,$type_s=false){
	$value_folder=(isset($form['force_folder']))? $form['force_folder'] : REP_IMG;
	$b = '	<form id="'.$form['id'].'" name="'.$form['id'].'" enctype="multipart/form-data" action="'.URL_ADMIN.'appel_fct.php?funct=include/lib/lib.xmedia.php&amp;act=upload&amp;sortie=&amp;vars='.@$form['vars'].'" method="post"  onsubmit="'
		 	."montre('ret_file_upload".$form['id']."');montre('onload');"
			."add_link_nav2('ret_file_upload".$form['id']."','#','<img src=\''+document.getElementById('up_file[".$form['id']."]').value+'\' alt=\''+document.getElementById('up_file[".$form['id']."]').value+'\' />', '');"
			.@$form['js']
			."cache_t('onload');"
			.'" target="myiframe_upload'.$form['id'].'">'
		.'<fieldset><legend>'.ADD_A_FILE_TO_THE_CURRENT_FOLDER .'</legend>'
		.'<p><span class="nowrap"><label for="up_file">'.sprintf( CHOOSE_FILE, (MAX_UPLOAD_SIZE)/1000000 ).'</label>'
		.'<input name="up_file['.$form['id'].']" id="up_file['.$form['id'].']" type="file" onclick="montre(\'bt_submit_up_'.$form['id'].'\')"/>'
		.'<input type="hidden" name="MAX_FILE_SIZE" value="'.MAX_UPLOAD_SIZE.'" />';

	if ($form['extract_zip']) $b .= '<label>'.EXTRACT_LEIZP.'</label><input type="radio" name="extract_zip" value="true" />';


	$b .= '<input type="radio" name="new_folder_for_zip" value="'.@$form['new_folder_for_zip']? 'true' : 'false'; '" />';
	$b .= '<input type="hidden" name="force_folder" value="'.$value_folder. '" />';

	$b .= '<input id="bt_submit_up_'.$form['id'].'" class="submit" type="submit" value="'.ADD_FILE.'" style="display:none" />'
		.'</span></p>'
		.'</fieldset>'
	.'</form>'
	.'<iframe name="myiframe_upload'.$form['id'].'" id="myiframe_upload'.$form['id'].'" style="margin:0;padding:0;border:none;height:100px" >'

	.'</iframe>'
	.'<div id="ret_file_upload'.$form['id'].'" style="display:none;"></div>';
	if ($type_s) print $b;
	else return $b;
}
?>