FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old October 19th, 2003, 01:30 PM
kaen kaen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 63 kaen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
uploading files to ftp via php

I have a problem. This is my code:

PHP Code:
<?
//Get FTP Pass, User, Server, and Category
 
$ftp "SELECT ftp_server, ftp_user, ftp_pass, ftp_cat, address FROM 

layout_servers where      ftp_cat = '$_SESSION[cat_id]'"

 
$ftp_res mysql_query($ftp) or die (mysql_error());

   while (
$row5 mysql_fetch_assoc($ftp_res)) 
    { 
        
$ftp_server $row5['ftp_server']; 
        
$address $row5['address']; 
        
$ftp_user $row5['ftp_user']; 
        
$ftp_pass $row5['ftp_pass']; 
        
$ftp_cat $row5['ftp_cat']; 
    }

$conn_id ftp_connect($ftp_server); 

// login with username and password
$login_result ftp_login($conn_id$ftp_user$ftp_pass); 


// check connection
if ((!$conn_id) || (!$login_result)) { 
        echo 
"FTP connection has failed!<br>";
        echo 
"Attempted to connect to $ftp_server for user $ftp_user"
        exit(); 
    } else {

ftp_chdir ($conn_id$_GET[type]);
ftp_mkdir ($conn_id$_GET[dirname]);

$dir "temp/$_GET[dirname]/";
$files = array();
$open opendir($dir);
while (
$file readdir($open)) { if ($file != "." && $file != "..") { $files[] = 

$file; } }
closedir($open);
sort($files);
reset($files);



for ( 
$i=0$i count($files); $i++ ) { 

//Upload
$source_file="temp/$_GET[dirname]/$files[$i]";
$destination_file="$_GET[dirname]/$files[$i]";

$upload ftp_put($conn_id$destination_file$source_fileFTP_BINARY); 

unlink($source_file);
}

if(
$upload) {

rmdir("temp/$_GET[dirname]");

echo 
"Files moved to $ftp_server";
echo 
"<img src=$address/$_GET[dirname]/$zip>";
        
} else {
echo 
"Error uploading. Contact the webmistress immediately.";
}    


}

// close the FTP stream
ftp_close($conn_id); 


//++++++++++++++++++++++++++++++++++++++
}
?>


However, once I upload the two images in the array- when I try to display them with this PHP script:

PHP Code:
<?
$thumb 
"$server/$cat/$item_id/$item_image";
?>


It says that it's broken. And if I go to the file address itself, it says that the image cannot be accessed. However, if I refresh, it works and works for the rest of the time.

Can you help me?
__________________
~ Kaen

Reply With Quote
  #2  
Old October 19th, 2003, 02:34 PM
jabba_29's Avatar
jabba_29 jabba_29 is offline
Back in HEL
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Feb 2002
Location: Finland
Posts: 8,670 jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)  Folding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner Folder
Time spent in forums: 3 Months 3 Weeks 4 Days 6 h 4 m 26 sec
Reputation Power: 1618
Send a message via ICQ to jabba_29 Send a message via AIM to jabba_29 Send a message via MSN to jabba_29 Send a message via Yahoo to jabba_29 Send a message via Google Talk to jabba_29 Send a message via Skype to jabba_29
Facebook
Hi, bit confussed

Where do these vars come from?
PHP Code:
 $thumb "$server/$cat/$item_id/$item_image"

Are they ftp links or http?
__________________
Cheers,

Jamie


# skiFFie | Home of the 'accessibility module' for Drupal
# Jamie Burns [me] Accessibility Module [drupal]
# guidelines | search | wap resources | not getting help | fold to cure

# Any form of employment is strictly prohibited ......


__________________

Let the might of your compassion arise to bring a quick end
to the flowing stream of the blood and tears .....
Please hear my anguished words of truth.

__________________

Reply With Quote
  #3  
Old October 19th, 2003, 04:12 PM
kaen kaen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 63 kaen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
well, on a seperate page, i pulled the information of the image out of my database- I just didn't show it to you. sorry ^^

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > uploading files to ftp via php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway