Jump to content

Image Upload Script


chasethemetal

Recommended Posts

Hey all!I've been able to find working examples of how to upload files via a browse your hard drive button then when click upload and it will place the file "LOCALLY" on my machine fine.But I've yet to find anythinggg on how to make a script that connects to my FTP server and then uploads the files there.Any guidance on how to connect to a remote server, and upload via a form button would be MUCH appreciated.Thank you.

Link to comment
Share on other sites

You have to upload to the web server first, but once the files are on the web server you can have it open a connection to an FTP server and send the files over there. If you want to skip the web server then you need to use an FTP client, not a form on a web page.

Link to comment
Share on other sites

You have to upload to the web server first, but once the files are on the web server you can have it open a connection to an FTP server and send the files over there. If you want to skip the web server then you need to use an FTP client, not a form on a web page.
Thanks!As a am somewhat of a beginner could you clear up what a web server is or illustrate how this process works in more detail?My basic setup right now, is my computer where the site sit's locally, then through an FTP program I upload it to my Lunar Pages server.I assume the web server aspect I would have to virtually create on my machine??? Any links or advice on how to set that up would be awesome!Thanks again.
Link to comment
Share on other sites

You can google it form WAMP or XAMPP,LAMP,MAMP. (for wndows,mac,linux respectively)it is package of whole thing includes the apache web serve,mysql,phpr which you going to need to. you need to download and install one of them.

As a am somewhat of a beginner could you clear up what a web server is or illustrate how this process works in more detail?
http://en.wikipedia.org/wiki/Web_serverhttp://en.wikipedia.org/wiki/Apache_HTTP_Server
Link to comment
Share on other sites

I am aware of MAMP and the such. But for what I was trying to do I realized the solution that doesn't involve a testing web server on my local machine. Here is a simple upload script I got working for everyone. The only issue I found is that the permissions on the destination folder you create may need to be modified for this to work correctly.---------<?if(!isset($_POST["submit"])){?><!-- THE FORM ACTION IS ONTO ITSELF --><form action="index.php" method="POST" enctype="multipart/form-data"><input name="userfile" type="file" size="40"><input type="submit" name="submit" value="Upload image" /></form><?}else { set_time_limit(30000);//i noticed that this had to be pretty big otherwise your upload was likely to stall out. $paths='/yourfilepath/yourfilepath/'; $filep=$_FILES['userfile']['tmp_name']; $ftp_server='ftp.yourdomain.com'; $ftp_user_name='your_user_name'; $ftp_user_pass='your_password'; $name=$_FILES['userfile']['name']; $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if ((!$conn_id) || (!$login_result)) { echo "FTP connection has encountered an error!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name...."; exit; } else { echo ""; } $upload = ftp_put($conn_id, $paths.'/'.$name, $filep, FTP_BINARY); if (!$upload) { echo "FTP upload has encountered an error!"; } else { echo "Uploaded file with name $name Succsessfully "; } ftp_close($conn_id); }?>-----------------

Link to comment
Share on other sites

Again... I can't seem to get this script to upload anything bigger than 200K.I have in my php.ini filepost_max_size = 20Mupload_max_filesize = 20Mand in my .htacces file I have putLimitRequestBody 2147483647which is the max it can go...yet still I can not upload anything bigger than 200K. Whats the deal? Any suggestions?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...