473,473 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

FTP problem

Well, I must say that I am new to working with FTP and am having problems
despite the good help I have recieved. I have been working with
code supplied by Janwillem Borleffs and have been able to get it to
connect to the ftp server on my dev machine (red hat/apache). What I am
trying to do is create a directory but the directory is not being created
(at least I don't see it in the expected directory) from an administrative
form so that annonomous users can upload files into it.

I think I am missing something here.
this
Expand|Select|Wrap|Line Numbers
  1.      $ftp = fsockopen("192.168.0.219", 21, $errno, $errstr, 30);
  2.  
opens the ftp connection. This address hosts several dev sites
including the one I need to create a directory in which I will name
site1_root. The URL to the site on my dev machine is
"192.168.0.219/site1_root". (what I type in the bwroser to get to the home
page).

This
Expand|Select|Wrap|Line Numbers
  1.   fputs($ftp, "cwd /site1_root/uploads/custom"); 
is
supposed to change directories. If I understand it correctly, this code is
writing to the handle($ftp) which should allow it to point to the proper
folder
where I want to create the new folder.

Below is the code for the whole page: When try to execute it, I get no
error msgs from the fputs command, but
Expand|Select|Wrap|Line Numbers
  1.    if
  2. (!file_exists("../uploads/custum/".$foldername)) { 
fails and let's
me know the folder does not exist.

The uploads folder has permissions set to '0777' for now.

I guess I'm all over the place in my comments here ... and I hate to ask
this question, but why doesn't this work?

Irvin <><
__________________________________________________ _________

<html>
<head>
<title>Untitled Document</title>
<meta name="robots" content="noindex">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
$errTxt="";
if($Submit) {
if (!file_exists("../uploads/custum/".$foldername)) {

$user = 'username';
$pass = 'password';
$dirname = "../uploads/custum/".$foldername;

// Connect
$ftp = fsockopen("192.168.0.219", 21, $errno, $errstr, 30);
fputs($ftp, "cwd /site_root/uploads/custom");

if (!$ftp) {
echo "$errno: $errstr<br>\n";
}else{
// Authenticate
if(!fputs($ftp, "user $user\r\n")) { echo "User Failed.<br>"; }
fgets($ftp, 1024);
if(!fputs($ftp, "pass $pass\r\n")) { echo "Pass Failed.<br>"; }
fgets($ftp, 1024);

// Make dir
if(!fputs($ftp, "mkd $dirname\r\n")) { echo "MKDIR Failed.<br>"; }

// Close
fputs($ftp, "quit\r\n");

fclose($ftp);
}

if (!file_exists("../uploads/custum/".$foldername)) {
$errTxt.="An unidentified error was encountered while<br> trying to
create the folder <b>'uploads/custum/$foldername'</b>.";
}else{
$errTxt.="<font-color='green'>The folder
<b>'uploads/custum/$foldername'</b> was sucessfully created.</font>";
}
}else{
$errTxt.="The folder <b>'uploads/custum/$foldername'</b> already esists.";
}

}
?>
<form name="form1" method="post" action="">
<table width="321" border="0" align="center" cellpadding="5"
cellspacing="0" bgcolor="#CCCCCC">
<tr bgcolor="#FFFFFF" class="mainheading">
<td><p>Add a New Custum Folder <span class="content"><br>
</span></p> </td>
</tr>
<tr class="content">
<td align="right"><div align="center">Enter the name of the folder
you wish to add:</div></td>
</tr>
<tr class="content">
<td align="right"><div align="center">
<input name="foldername" type="text" class="content" id="foldername"
value="<?php echo $foldername?>" size="50">
</div></td>
</tr>
<tr class="content">
<td><div align="center">
<input name="Submit" type="submit" class="content" value="Add
Folder">
</div></td>
</tr>
<tr class="content">
<td><div align="center"><span class="contentBoldRed"><?php echo
$errTxt ?></span></div></td>
</tr>
<tr class="content">
<td bgcolor="#FFFFFF"><div align="center"><a href="browse.php">Return
to Folder Contents </a></div></td>
</tr>
</table>

</form>
</body>
</html>
Jul 17 '05 #1
0 2884

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
18
by: Ian Stanley | last post by:
Hi, Continuing my strcat segmentation fault posting- I have a problem which occurs when appending two sting literals using strcat. I have tried to fix it by writing my own function that does the...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: =?Utf-8?B?am8uZWw=?= | last post by:
Hello All, I am developing an Input Methop (IM) for PocketPC / Windows Mobile (PPC/WM). On some devices the IM will not start. The IM appears in the IM-List but when it is selected from the...
1
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.