I am trying to build a file upload function into my form class, but am having some difficulty. A sample of the script is running at:
http://www.vortexstudio.com/vendor/test.php
The script returns this error:
"Warning: Unable to open 'C:\Documents and Settings\Brian Wurster\Desktop\P1010002.JPG' for reading: No such file or directory in /home/.chippy/bwurster/vortexstudio.com/vendor/obj/form.php on line 288"
I feel like the problem is this...
- The HTML file form element is called "image"
- When the form is submitted the field "image" contains a pointer to the file on the user machine, correct?
- When I pass this image value to the class function it is not able to find the file on the user machine to perform the "copy" command
- Hence, the file is never uploaded and the resulting error occurs
Does anyone know how to process a file upload from within a class function? Is it possible to access some of the $image_name, $image_size, $image_type variables from the $HTTP_POST_FILES from within the class function? I am under a deadline to get this right, and could really use some advice on solving this problem. Here is a copy of the relevant code:
function createJPEGThumbnail($imagePointer, $saveDir, $thumbnailWidth, $fullSizeWidth) {
if(file_exists($saveDir)) {
print("Save Directory Exists<br>");
} else {
print("Save Directory Doesn't Exist<br>");
}
if(is_writable($saveDir)) {
print("Save Directory Is Writable<br>");
} else {
print("Save Directory Is Not Writable<br>");
}
$imageURL = $this->values["image"];
$imageName = $this->parseLast($imageURL, "\\");
$imageExtension = $this->parseLast($imageName, ".");
print("<b>Local File Path: </b>$imageURL<br>");
// copy file to local directory
$tempDir = $saveDir . $imageName;
print("<b>Save Path: </b>$tempDir<br>");
copy($imagePointer, $tempDir);
}