Question:
PHP code, upload graphic to a website?
jlp.media
2006-11-09 08:26:34 UTC
a have a website and i want the user to be able to upload graphics to the site so i can later extract them.
does any one know a code that i can just drop into my html code?
or does any one want some quick cash by doing it for me?
Four answers:
2006-11-09 19:03:06 UTC
Here is one way to do it... although I prefer to do the uploads on my site with the php FTP functions (shown below).



$uploaddir = '/var/www/uploads/';

$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);



if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {

echo "File is valid, and was successfully uploaded.\n";





----------------------------------------------------------------------------------------------------

FTP--




// set up basic connection

$conn_id = ftp_connect($ftp_server);



// login with username and password

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);



// check connection

if ((!$conn_id) || (!$login_result)) {

echo "FTP connection has failed!";

echo "Attempted to connect to $ftp_server for user $ftp_user_name";

exit;

} else {

echo "Connected to $ftp_server, for user $ftp_user_name";

}



// upload the file

$upload = ftp_put($conn_id, $destination_file, $source_file, 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_close($conn_id);

?>

} else {

echo "File upload failed!\n";

}
dm_gsxr
2006-11-09 09:01:01 UTC
If you have the money to pay for a quick snip of code, you might just buy the PHP Hacks book. I believe it has the bit of code you're looking for. You can also go to safari.oreilly.com and apply for a 14 day membership and just read the hacks book on line. Also, php.net has lots of good bits of code. A little searching will find your solution.
tutejasaurabh
2006-11-13 02:25:02 UTC
There is a simple way in html that allows to upload files and a simple execution in php allows you to manage those.

It goes like this :

use input type "file" in the html form.

i.e. do something like this



Use the global array $_FILES in php to get various parameters of file being uploaded and manipulate it.
2016-03-19 09:47:47 UTC
Get someone who can code to help you or get a good WYSIWIG editor.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...