View Issue Details

IDProjectCategoryView StatusLast Update
0007660mantisbtattachmentspublic2014-01-29 15:50
ReporterCakeman Assigned Tovboctor  
PrioritynormalSeveritymajorReproducibilityhave not tried
Status closedResolutionwon't fix 
PlatformIIS 6 php4OSWindows 2003 
Product Version1.0.6 
Summary0007660: FTP method
Description

Hello,

I have found a bug I think concerning the file upload with FTP. The code is:
Quote:
switch ( $t_method ) {
case FTP:
case DISK:
file_ensure_valid_upload_path( $t_file_path );

if ( !file_exists( $t_disk_file_name ) ) {
if ( FTP == $t_method ) {
$conn_id = file_ftp_connect();
file_ftp_put ( $conn_id, $t_disk_file_name, $p_tmp_file );
file_ftp_disconnect ( $conn_id );
}

if ( !move_uploaded_file( $p_tmp_file, $t_disk_file_name ) ) {echo $p_tmp_file.'!!!'. $t_disk_file_name ;
trigger_error( FILE_MOVE_FAILED, ERROR );
}
chmod( $t_disk_file_name, 0400 );

$c_content = '';
} else {
trigger_error( ERROR_FILE_DUPLICATE, ERROR );
}
break;

But it does not work on php on IIS. Indeed, you put the file on the FTP serveur with:
Quote:
if ( FTP == $t_method ) {
$conn_id = file_ftp_connect();
file_ftp_put ( $conn_id, $t_disk_file_name, $p_tmp_file );

And after, you try to move the file with:

Quote:
if ( !move_uploaded_file( $p_tmp_file, $t_disk_file_name ) ) {echo $p_tmp_file.'!!!'. $t_disk_file_name ;
trigger_error( FILE_MOVE_FAILED, ERROR );
}

It is not logical because $t_disk_file_name is the name on the FTP serveur and not the webserveur !!!
It doesnot matter with apache (no error) but not with IIS. Moreover the function chmod is dangerous.

I mke a little correction:
Quote:
switch ( $t_method ) {
case FTP:
file_ensure_valid_upload_path( $t_file_path );

if ( !file_exists( $t_disk_file_name ) ) {
if ( FTP == $t_method ) {
$conn_id = file_ftp_connect();
file_ftp_put ( $conn_id, $t_disk_file_name, $p_tmp_file );
file_ftp_disconnect ( $conn_id );
}
} else {
trigger_error( ERROR_FILE_DUPLICATE, ERROR );
}
break;
case DISK:
file_ensure_valid_upload_path( $t_file_path );

if ( !file_exists( $t_disk_file_name ) ) {
if ( !move_uploaded_file( $p_tmp_file, $t_disk_file_name ) ) {echo $p_tmp_file.'!!!'. $t_disk_file_name ;
trigger_error( FILE_MOVE_FAILED, ERROR );
}
chmod( $t_disk_file_name, 0400 );

$c_content = '';
} else {
trigger_error( ERROR_FILE_DUPLICATE, ERROR );
}
break;

It works very well.
Only one problem: There is no cache with file uploaded on the webserveur. But I think it is normal because FTP method allows us to have the file on an other server.

Steps To Reproduce

$g_allow_file_upload = ON;
$g_absolute_path_default_upload_folder = '/';

Tehn try to upload files

TagsNo tags attached.

Relationships

related to 0016849 closedvboctor Drop FTP support 
has duplicate 0007659 closedvboctor FTP method 
has duplicate 0003734 closedgrangeway FTP upload feature is completely buggy!!! 
has duplicate 0005427 closedgrangeway FTP function 

Activities

Cakeman

Cakeman

2006-12-15 10:02

reporter   ~0013833

In the FTP method, $g_absolute_path_default_upload_folder seems to represent the path on the ftp serveur and not on the web server

Cakeman

Cakeman

2006-12-15 10:04

reporter   ~0013834

To correct all the problem you must modify download_file.php:

$ftp = file_ftp_connect();
file_ftp_get ( $ftp, $v_filename, $v_diskfile );
file_ftp_disconnect( $ftp );
readfile( $v_filename );
unlink ( $v_filename );

grangeway

grangeway

2012-02-05 18:56

reporter   ~0031153

Merging issue 5427 into this one - that also talks about the case whether there should be two paths - web server path + ftp path

vboctor

vboctor

2014-01-19 19:34

manager   ~0039099

See 0016849 - this feature is being deprecated.