Having some problems uploading a file to my server, via a web form. This worked with my old Windows webhosting account. Now I am on a Unix platform. I believe I fixed everything that needed to be fixed ... such as the new path, and setting the folder permission to writeable ... but it still isnt working. Here is the code. A little sloppy, but as I said, it worked on my old server....
Form on Page 1:
<?php
$i=1;
// LOOP so all 4 files get uploaded
do {
?>
<input type="file" name="file<? echo $i; ?>" size="30">
<?php
$i++;
} while ($i<5);
?>
Page 1 sends the form fields to Page 2, which contains:
if(isset($_POST['file1'])) { $file1 = $_POST['file1']; }
if(isset($_POST['file2'])) { $file2 = $_POST['file2']; }
if(isset($_POST['file3'])) { $file3 = $_POST['file3']; }
if(isset($_POST['file4'])) { $file4 = $_POST['file4']; }
// Gets $file variable from form....
// This may be were the error is occuring ...
// ... as it's not just a variable being transfered, but a complete file ...
// Path on server ... "temp" directory is CHMOD 777 and writeable.
$serverpath = "/home/cust1/user123456789/html/temp/";
// I checked with my webhost, and the path is correct.
// But are there leading slashes? And is a slash needed at the end?
$i=1;
// LOOP so all 4 files get uploaded
do {
if (${"file$i"}) // If file exists ...
{
$fileonserver = $serverpath."".${"file".$i."_name"};
// IF FILE ERRORS...
if (${"file$i"} == "none")
{ $error = "File Error - No file uploaded for section ".$i; }
if (!$error)
{
// BEGIN FILE UPLOAD
copy(${"file$i"}, "$fileonserver");
unlink(${"file$i"});
${"sec".$i."file"} = ${"file".$i."_name"};
// FILE UPLOADED
}
}
$i++;
} while ($i<5);
Please let me know if you can tell me what is wrong. I'm a newbie with PHP so please be patient and explain carefully ... I tend to get confused easily. :queasy: