Jump to content


Photo

upload field


  • Please log in to reply
6 replies to this topic

#1 dandandan

dandandan
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 15 September 2006 - 03:48 AM

how can i make a upload field? Like on a page, a imput box, with a browse button, when you push submit it uploads whats in the imput box onto your server. ???? please help.

#2 JustinK101

JustinK101
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego, California, US

Posted 15 September 2006 - 04:06 AM

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:

        <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)">

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.

#3 dandandan

dandandan
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 15 September 2006 - 05:01 AM

i tried to Pm you put it says im not allowed to send personal messages. could you post a link to the script here?

#4 JustinK101

JustinK101
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego, California, US

Posted 15 September 2006 - 07:28 AM

Well the script I wrote I don't freely distrubte. Would you be intested in paying for it.  Very cheap, only $20 and I'll help you install and configure it. It allows you to set allowed file extensions, max file size, and max width and height for images. Robust!

#5 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 15 September 2006 - 07:31 AM

<?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);
?>

#6 JustinK101

JustinK101
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego, California, US

Posted 15 September 2006 - 07:34 AM

markbett: Thats certainly a quick and dirty.

#7 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 15 September 2006 - 07:42 AM

never asked for fancy and free = quick and dirty... anyways its a starting point ... they can customize for their own needs




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users