Ok so basically I am creating a ftp loop, that takes dynamic inputs from a previous page (all variables should be present, but naturally may not be formatted correctly... or i wouldnt be posting)

So.. I can get it to loop through a connection just fine, but I seem to be having issues with $source_file and $destination_file as they print nothing on the page, and I get an ftp put error

Warning: ftp_put(): No file name in processFiles.php on line 228
FTP upload has failed!

If I could get someone to look at this and tell me whats going on.. I know that some of the other things may be wonky, but what I need help on is the destination and the source.... well, that and getting it to loop properly through to put the images in the right folders... any help would be appreciated


///checks the database
$host = "sqlhost" ;
$user = "sqlusername" ;
$pass = "sqlpass" ;
$db = "sqldbname" ;

$show_all = "SELECT * FROM $table ORDER BY Idnum";

mysql_connect ($host,$user,$pass) or die ( mysql_error ());
mysql_select_db ($db)or die ( mysql_error ());
$result = mysql_query ($show_all) or die ( mysql_error ());


while ($counter <$x){

// this counts the season folders
while ($dircount=readdir($falldn))
closedir ($falldn);


while ($dircount=readdir($winterdn))
closedir ($winterdn);


while ($dircount=readdir($summerdn))
closedir ($summerdn);


while ($dircount=readdir($springdn))
closedir ($springdn);

// end folder count

///upload image
// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

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

// upload the file


if ($category=="seasons"){
	if ($seasons=="fall"){
	elseif ($seasons=="winter"){
	elseif ($seasons=="summer"){
	elseif ($seasons=="spring"){

elseif ($products=="products"){
elseif ($radio=="image"){
print("<br>Source File: ".$source_file."<br>");
print("Destination File: ".$destination_file."<BR>");

///upload script
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);

// check upload status
if (!$upload) {
        echo "FTP upload has failed!";
    } else {
        echo "Uploaded $source_file to $ftp_server as $destination_file<BR><BR>";
    ///end upload script

///end upload file if file size is >0

// close the FTP stream
///end upload image

8 Years
Discussion Span
Last Post by atrophiedsoul

ok, then lets look at just what I am wanting to do... IE pull dynamic variables and in the end tell the php which folder to put them in as a loop

basically the person enters a category from a radiogroup on the previous page, its either a season, a product or an image.

it takes THAT category and then input from the drop downs that accompany (seasons obviously gets 1 of 4 selections thats passed) and products which has a large list with an Idnum sent.

now, the script has to look at these and go basically:

for each season that comes up, which season was it?... then put it in the right folder.

for products, it looks at the idnum and saves the image as $idnim.jpg

for images, it doesnt really care, it just saves it to a set folder, no renaming needed, although it DOES have to pick up the name from the specific dynamic userfile

my dynamic count variable from the previous page gets assigned as $x=$_POST['uploadneed']; and as you can see, I have the other variables being figured out as their dynamic versions:


now im not sure that $imagename is formatted correctly, as i said both destination and source prints nothing out, so probably do not have them formatted correctly.


the previous form, that sends data to this page, looks like this

<form name="fileup" method="post" enctype="multipart/form-data" action="processFiles.php">
  // start of dynamic form
  $uploadNeed = $_POST['uploadNeed'];
<input name="userfiles<?php echo $x;?>" type="file" id="userfiles<?php echo $x;?>">
<input name="radio<?php echo $x?>" type="radio" value="seasons" />Seasons
<input name="radio<?php echo $x?>" type="radio" value="products" />Products
<input name="radio<?php echo $x?>" type="radio" value="Images" />Images<BR />
<?php include('includes/seasons.php'); ?>
<?php include('includes/products.php'); ?><BR /><BR /></font>
  // end of for loop
  }  ?>

gah... stupid forum ate half my response. :(


so, yes basically the first page sets up how many upload fields are needed (requested by the client to be this way) then sends that information to the second page which then creates that many upload fields, radio groups and dropdowns (1 radio group and 2 dropdowns per upload field).

the process page looks at that and is suppose to loop through all information sent and put the files in the correct location based on the choices form the radio group and the drop downs..

the problem I seem to be having is somewhere in the way I am trying to recover the sourcefile (tmp name) and destination name (filename) from the $_FILES superglobal.

nothing is being printed, so i assume i am not actually retreiving the names correctly


I fixed it... yay... i used switch conditions

switch ($category){
	case 'seasons':

	case 'products':
	case 'images':
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.