|
|
|
<?php
/*
***************************************************************************************
***************************************************************************************
*/
prepare a form similiar to this and have it call the below file
echo '<form action="image_upload.php" method="post" enctype="multipart/form-data">';
echo 'Click the Browse button to find the file you wish to upload';
echo '<input type="file" name="imagefile">';
echo '<INPUT TYPE="submit" name="upload" value="upload">';
echo '</form>';
/**************************************************************************************
***************************************************************************************
***************************************************************************************
*** <input type="file" name="imagefile"> ***
*** with the above tag declared in the calling form ***
*** the variable name is $imagefile and the available properties are ***
*** $imagefile :name of the file as stored on the temporary server directory ***
*** $imagefile_name :filename.extension of the file as on the users machine ***
*** $imagefile_size :size in bytes of the file ***
*** $imagefile_type :the type of file image/gif image/jpg text/html etc.... ***
*** ***
***************************************************************************************
***************************************************************************************
*/
//change these values to suit your site
$ftp_user_name='XXXXXXXX';
$ftp_user_pass='XXXXXXXX';
$ftp_server='ftp.YOURSITE.com';
$ftp_dir='/YOURSITE.COM/public_html/upload/';
//$web_location is needed for the file_exists function, the directories used by FTP
//are not visible to it will will always return not found.
$web_dir='../upload/';
$web_location=$web_dir.$imagefile_name;
//build a fully qualified (FTP) path name where the file will reside
$destination_file=$ftp_dir.$imagefile_name;
// connect, login, and transfer the file
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
$upload = ftp_put($conn_id, $destination_file, $imagefile, FTP_BINARY);
//use ftp_site to change mode of the file
//this will allow it be visible by the world,
$ch=ftp_site($conn_id,"chmod 777 ".$destination_file);
// close the FTP stream
ftp_close($conn_id);
//verify file was written
if (file_exists($web_location))
{
echo "file was uploaded as $web_location";
}
else
{
echo "Could not create $web_location";
}
//end if
?>
|
|
| Opening and formatting text files into HTML on the fly- or HTML from templates. Categories : PHP, HTML and PHP, Filesystem | | | Handle multiple file upload Categories : Complete Programs, Filesystem, PHP, HTML and PHP | | | Directory viewer, customize how you display the file structure, easy to
understand. Found out about PHP 3 days ago, and this is my first prog. Categories : HTML and PHP, Complete Programs, Directories, Filesystem, PHP | | | How to let a user download a picture by clicking on it instead of needing to right click and Save-As. Categories : HTTP, PHP, HTML and PHP, Filesystem | | | A simple php file uploader Categories : PHP, Filesystem, HTML and PHP | | | Open directory and File download Categories : PHP, Filesystem, Directories, HTML and PHP | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | Directory TreeView - File Manager & Explorer - FTP - Utility - PHP/HTML - Categories : PHP, Directories, FTP, Filesystem, HTML and PHP | | | Random Image Display Categories : PHP, Filesystem, Graphics, HTML and PHP | | | Sed, a coder's best friend. This lovely linux command allows you to swap strings in a file. Great for changing a variable name in a script with
multiple files. Categories : HTML and PHP, HTML and PHP | | | Local-to-user date and time display regardless of time zone or where the website's server is located Categories : PHP, Date Time, HTML and PHP, Java Script | | | Record Set Paging with PHP (RSP) Categories : PHP, MySQL, Navigation, Databases, HTML and PHP | | | The Nearly Perfect Contact Us Form Categories : PHP, Form Processing, HTML and PHP | | | Parse html (title :: meta) Categories : PHP, HTML and PHP, Regexps | | | webcam cam view image ispy browser independant Categories : Graphics, HTML, HTML and PHP, PHP | |
|
|