Jump to content

upload field


dandandan

Recommended Posts

Well the HTML is quite simple, but the php code to acutally upload and store the file is way more complex. The html looks like:

[code]
        <form name="f" enctype="multipart/form-data" action="'.  $_SERVER['PHP_SELF'] .'" method="POST">
          <input type="hidden" name="submitted" value="true">
          <input type="hidden" name="language" value="en">
          <strong>Upload Image:</strong><input name="'. $upload_file_name .'" type="file" size="48">
          <input type="button" value="Upload Image" name="submitbutton" onClick="check(this.form)">
[/code]

Again, the PHP code is much more complex. I can assist further, please send me a Private Message, I have an upload class script I wrote that is quite solid and works well.
Link to comment
Share on other sites

<?php
// variables
$ftpServer = "hostAddress";
$ftpUser = "userID";
$ftpPass = "password";
$finalDir = '/httpdocs/km/tmp/';
$finalFile = $finalDir . $_FILES['userfile']['name'];
$sourceFile = $_FILES['source_file']['tmp_name'];

// Connect and echo result
$ftpConn = ftp_connect("$ftpServer");
$ftpResult = ftp_login($ftpConn, $ftpUser, $ftpPass);
ftp_pasv($ftpConn, true);
if ((!$ftpConn) || (!$ftpResult))
echo "Connection failed<br><br>";
else
echo "Connection succeeded<br><br>";

// upload the file
$ftpUpload = ftp_put($ftpConn, $finalFile, $sourceFile, FTP_BINARY);

// check upload status
if (!$ftpUpload)
echo "FTP upload has failed!";
else
echo "Uploaded $sourceFile to $ftpServer as $finalFile";

// close the FTP stream
ftp_close($ftpConn);
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.