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
- $ftp = fsockopen("192.168.0.219", 21, $errno, $errstr, 30);
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
- fputs($ftp, "cwd /site1_root/uploads/custom");
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
- if
- (!file_exists("../uploads/custum/".$foldername)) {
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>