I have a page with which I am trying to edit a product's images (there are two). The value of my $HTTP_POST_FILES['uploadfiles'][0] is blank but it seems to be set when I check using isset. Below is the code can anyone help?? Or have a better method for managing files associated with a record? Thanks!
(The images are stored in a directory with the name being stored in a MySQL db.)
Using portion of code from the php.net manual for multiple file uploads.
*Note: trying to get value of first input type=file name=uploadfiles[]
$path_to_file = '/home/www/website/images/';
$files = $HTTP_POST_FILES['uploadfiles'];
if(!isset($files['name'][0])){
$smlpicset = str_replace("%20", "_", strtolower($files['name'][0]));
if (!ereg("/$", $path_to_file)){
$path_to_file = $path_to_file."/";
}
if ($files['size'][0]) {
// clean up file name
$name = ereg_replace("[^a-z0-9._]", "",
str_replace(" ", "_", str_replace("%20", "_", strtolower($name))));
$location = $path_to_file.$name;
while (file_exists($location))
$location .= ".copy";
copy($files['tmp_name'][0],$location);
unlink($files['tmp_name'][0]);
echo "\n Successfully uploaded file: $name.<br>";
}
else {
echo "image failed during upload";
}
else{
echo "New Image not set;
}
I was able to upload the files I just can't figure out a process to edit them