note 26317 deleted from function.move-uploaded-file by sniper
| From: | sniper@php.net | Date: | Tue, 28 Jan 2003 05:17:29 +0000 |
| Subject: | note 26317 deleted from function.move-uploaded-file by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-42906@lists.php.net to get a copy of this message | ||
At php-safe-mode, this function doesn't works, but sometimes we need to give the user the
privilege for upload file (like their photos)
One Solution I figured out is to make a little ftp program, and then upload the file from
/tmp/filename000 to your webroot. Simple as your machine to your own machine... here is the source
code for a little Program I maked:
---------- THE FILE BEGINS HERE --------
// ftp.php
<?php
// set up basic connection
if ($fichier) {
$destination = $fichier_name;
$destination = STR_REPLACE(" ","",$destination);
if (copy($fichier, $destination)) {
echo "$destination saved";
} else {
echo "Error saving file";
}
}
$ftp_server = "ftp.your.server.com";
$username = "yourusername";
$password = "yourpassword";
$pubic_dir = "/home/edurango/www"; // the webroot or the place where you want to move the
file.
$conn_id = ftp_connect( $ftp_server );
// login with username and password
$login_result = ftp_login($conn_id, $username, $password);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
die;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}
//$dir = ftp_rawlist ( $conn_id, $pubic_dir);
//print_r ($dir);
// upload the file
$upload = ftp_put($conn_id, $pubic_dir."/".$destination, $destination, FTP_BINARY);
// check upload status
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}
// close the FTP stream
ftp_quit($conn_id);
?>
<html>
<head>
<title>Subir imagen</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.submitAzul { font-family: Geneva, Arial, Helvetica, san-serif; font-size: 16px; color: #333333;
text-decoration: none; background-color: #CCCCCC; font-weight: bold}
-->
</style>
</head>
<body bgcolor="#333333" text="#CCCCCC" link="#FFFFFF"
vlink="#FFFFFF" alink="#FFFFFF" leftmargin="0" topmargin="0"
marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0"
cellpadding="0" height="100%">
<tr>
<td align="center" valign="middle">
<form name="form1" enctype="multipart/form-data"
method="post" action="<? echo $PHP_SELF; ?>">
<p>
<input type="file" name="fichier">
<input type="submit" name="Submit" value="Subir"
class="submitAzul">
</p>
</form>
</td>
</tr>
</table>
</body>
</html>
------------ THE FILE ENDS HERE -----------
Just copy and paste that code, configure the server, username, password and webroot and run it.