In my script i have 3 page: invio.php, makedir.php and upload.php
in invio.php i have the form for user data:
- Code: Select all
<form id="form1" name="form1" method="post" action="new_makedir.php" enctype="multipart/form-data">
<input type="text" name="azienda" id="azienda2" />
this page submit the variable azienda to makedir.php, this page create a folder on ftp with the name in the variable. I create the session called "azienda" because I need to post this variable to the page upload.php.
- Code: Select all
<?php
session_start();
$cartella = $_POST['azienda'];
$login = 'xxx';
$password = 'xxx';
$conn = ftp_connect('xx.xx.xx.xx') or die('Could not connect');
@ftp_login($conn, $login, $password);
$cartella = str_replace(' ', '_', $cartella);
@ftp_mkdir($conn, $cartella);
@ftp_chdir($conn, $cartella);
$_SESSION['cartella'] = $cartella;
?>
In this page i have a flash uploader that called upload.php
- Code: Select all
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="544" height="281" id="MultiFileUploader" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="MultiFileUploader.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="MultiFileUploader.swf" quality="high" bgcolor="#ffffff" width="544" height="281" name="MultiFileUploader" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
the page upload.php take the file and send it to the ftp server
- Code: Select all
<?php
<?php
session_start();
print_r($_SESSION);
$cartella_up = $_SESSION['cartella'];
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$login = 'xyz';
$password = 'xyz';
$conn = ftp_connect('xx.xx.xx.xx') or die('Could not connect');
@ftp_login($conn,$login,$password);
ftp_put($conn, "{$cartella_up}/{$_FILES['Filedata']['name']}", $tempFile, FTP_BINARY);
ftp_close($conn);
}
?>
and here we have the problem....
the script make the upload of files but only in the root directory, it not recnognize the variable with the name of ftp directory...
but if I specify the name of directory it work perfectly, for example if I change $cartella_up to "test1234" it work perfectly!
have you any idea for the reasonf of this problem.
king regards



