here is the generic html for uploading:
<? /* ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Upload a File</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2800.1276" name=GENERATOR></HEAD>
<BODY>
<H1>Upload a File</H1>
<FORM action=do_upload.php method=post encType=multipart/form-data>
<P><STRONG>File to Upload:</STRONG><BR><INPUT type=file size=30 name="img1"></P>
<P><INPUT type=submit value="Upload File" name=submit></P></FORM></BODY></HTML>
<? */ ?>
<html>
<head></head>
<body><form enctype="multipart/form-data" action="do_upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
</body>
</html>
the following is a sampling of the code that i have tried:
/* if ($photo != "") {
$photo = addslashes(fread(fopen($photo, "r"), filesize($photo)));
} else {
$photo = "";
} */
$path = "/hsphere/local/home/mikalj/autobodyusainc.com/parts/images";
$uploadFile = $uploadDir.$_FILES['photo']['name'];
@copy($_FILES['photo']['name'], "$path/".$_FILES['userfile']['tmp_name'])
or die("Couldn't copy the image to the server.");
fopen($_FILES['photo']['name'], "r");
and the follwing is from a second script...some of this comes from PHP's own help file:
<?
/*
if ($_FILES['img1']['name'] != "") {
echo $_FILES['img1']['name'];
@copy($_FILES['img1'], "/var/www/html/steve/mng/".$_FILES['img1']['name'])
or die("Couldn't copy the file.");
} else {
die("No input file specified");
}
<HTML>
<HEAD>
<TITLE>Successful File Upload</TITLE>
</HEAD>
<BODY>
<H1>Success!</H1>
<P>You sent: <? echo "$img1_name"; ?>, a <? echo "$img1_size"; ?>
byte file with a mime type of <? echo "$img1_type"; ?>.</P>
</BODY>
</HTML>
*/
?>
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES. In PHP versions earlier than 4.0.3, use copy() and
// is_uploaded_file() instead of move_uploaded_file.
/* $path = "/hsphere/local/home/mikalj/autobodyusainc.com/parts/images";
$uploaddir = '/images/';
$uploadfile = $path . $_FILES['userfile']['name'];
echo $_FILES['userfile']['name']."<br>asdf<br>";
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>"; */
$openFile = $_FILES['userfile']['name'];
$remoteFile = $_FILES['userfile']['tmp_name'];
$ftp_server = "web3.thisismyserver.net";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
$ftpUser = "****";
$ftpPass = "*****";
$login_result = ftp_login($conn_id, $ftpUser, $ftpPass) or die("couldnt connect to ftp server");
$chDir = ftp_chdir($conn_id, '/autobodyusainc.com/parts/images');
echo "current directory is ".ftp_pwd($conn_id);
$putFile = ftp_put($conn_id, $remoteFile ,$openFile, FTP_BINARY) or die("couldnt upload file via ftp");
ftp_close($conn_id);
//fclose($file);
?>
This is the output i get when using the following:
echo("POST<br />\n");
print_r($_POST);
echo("GET<br />\n");
print_r($_GET);
echo("FILE<br />\n");
print_r($_FILE);
And here is the output that is displayed to the browser using my local testing server:
POST
Array ( [MAX_FILE_SIZE] => 30000 ) GET
Array ( ) FILE
Array ( [userfile] => Array ( [name] => 2004-03-13s.jpg [type] => image/pjpeg [tmp_name] => /tmp/phpnqp3wa [error] => 0 [size] => 8488 ) )
Remote server:
POST
Array ( [MAX_FILE_SIZE] => 30000 ) GET
Array ( ) FILE
Array ( )
Note that I used the same file for both of these and can successfully upload using the copy function on testing server but not on remote server. Also, I use GET, POST, FILES, and REQUEST (on occasion) and redeclare variables using these.
I did a phpinfo() and gathered that it would let me upload files up to 2M but even using their control panel script it would not let me upload files to the server.