Menu
ok i have a connection script and everything and it works but now i need like a form like freewebs has that allows u to browse through your computers files and then when u select one and hit upload it enters the right information into the variable in the script and cuts it down to the short filename and then uploads it and i was wondering if anyone knows where i could find one or if someone could make one pls and ty
[code=php]<html>
<body>
<?php
$file = 'somefile.txt';
$remote_file = 'readme.txt';
$ftp_user_name = 'myusername';
$ftp_user_pass = 'mypassword';
$ftp_server = 'ftp.bowhuntr.net';
// 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);
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $filen";
} else {
echo "There was a problem while uploading $filen";
}
// close the connection
ftp_close($conn_id);
?>
</body>
</html>[/code]
[code=php]
// path to save file to
$UploadDir = 'images/uploads/';
$UploadFileName = $UploadDir . $_FILES['image']['name'];
if (move_uploaded_file($_FILES['image']['tmp_name'], $UploadFileName)) {
print 'Photo upladed';
}else{
print 'error';
}//end this upload form
[/code]
[code=php]<html>
<body>
<?php
$file = 'somefile.txt';
$remote_file = 'readme.txt';
$ftp_user_name = 'myusername';
$ftp_user_pass = 'mypassword';
$ftp_server = 'ftp.bowhuntr.net';
// 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);
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $filen";
} else {
echo "There was a problem while uploading $filen";
}
// close the connection
ftp_close($conn_id);
?>
</body>
</html> [/code]
with your code, taking out all the necesary parts and inserting the correct stuff please and could u please tell me if i need to make any changes with the form [code=html]<html>
<body>
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="php.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
</html>
</body>[/code]
please and thanks so very much[code=php]
<html>
<body>
<?php
// path to save file to
$UploadDir = 'images/uploads/';
$UploadFileName = $UploadDir . $_FILES['userfile']['name'];
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $UploadFileName)) {
print 'Photo upladed';
}else{
print 'error';
}//end this upload form
?>
</body>
</html>
[/code]
Just set the default path ie: [b]$UploadDir = 'images/uploads/'; [/b][code=php]<?php
define('PASSWORD', 'password'); // edit second argument
$destination_directory = './'; // fill in
$errors = array('1' => 'file size over PHP limit', '2' => 'file size over form limit',
'3' => 'file only partially uploaded', '4' => 'no file specified');
$form = '
<form action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Password: <input type="password" name="password" value="'.@$_POST['password'].'"><br>
Upload: <input type="file" name="file"><br>
<input type="submit" name="submit" value="Upload">
</form>
';
(@$_POST['submit'])
or exit($form);
(PASSWORD == $_POST['password'])
or exit('<span style="color:red;">Incorrect password</span><br><br>'.$form);
(!(@$_FILES['file']['error']))
or exit('<span style="color:red;">Upload error: '.$errors[$_FILES['file']['error']].'</span><br><br>'.$form);
(!file_exists($destination_directory.$_FILES['file']['name']))
or exit('<span style="color:red;">Error: a file with that name already exists</span><br><br>'.$form);
(@move_uploaded_file($_FILES['file']['tmp_name'], $destination_directory.$_FILES['file']['name']))
or exit('<span style="color:red;">Error: not allowed</span><br><br>'.$form);
print 'File saved ok. <a href="'.$_SERVER['PHP_SELF'].'">Upload another?</a>';
?>[/code]
im pretty sure u messed up somehow[/QUOTE]Really! There is nothing wrong with that script. Did you actually try to run it?
well im setting it to the "/" directory and i "write to" it all the time'./' refers to the directory the script is located in but you could try specifying with an absolute path as follows:
more actueratly it says in that spot "./" so is that wrong?[/QUOTE]
[code=php]//The following specifies the root directory
$destination_directory = $_SERVER['DOCUMENT_ROOT'].'/';[/code]
[code=php]
$destination_directory = './,new_folder_name_here>'; /* add the new folders name with the 0777 chmod /*
[/code]
0.1.9 — BETA 5.28