class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
Hey there, we've spoken a ways back. I have a commercial license and am currently trying to integrate your class with Multipowupload, a Flash-based front-end replacement to the standard HTML form that will show status of uploads (http://www.element-it.com/MultiPowUpload.aspx). From what I can gather, this component does not submit an array (like myfield[], instead it automatically names inputs with an incrementing number. My question is, how can I still use your class while not doing the foreach at the start to get things properly set up for processing? Thanks for any help!Reply
Hmm, interesting on the local files approach, hadn't really looked at that. I guess I still wonder then at how to go through the files I've just uploaded with this module. This is the out of the box snippet that works:
if(count($_FILES) > 0) {
$arrfile = pos($_FILES);
$uploadfile = $uploaddir . basename($arrfile['name']);
if (move_uploaded_file($arrfile['tmp_name'], $uploadfile))
echo "File is valid, and was successfully uploaded.\n";
} else
echo 'No files sent. Script is OK!'; //Say to Flash that script exists and can receive files
echo 'Here is some more debugging info:';
print_r($_FILES);
So it's populating $_FILES as you say, but not with a named array (sorry, that's horribly wrong wording) like with your example: $_FILES['myfield']Reply
My upload page code with local processing (not working yet) new!
include('/uploadclass/class.upload.php');
function makeMyDir($inDirName) {
$dirArray = split('/', $inDirName);
$dirName = '/';
foreach ($dirArray as $dirLevel) {
$dirName .= $dirLevel.'/';
if (!file_exists($dirName)) {
mkdir($dirName, 0755);
}
}
}
echo 'Upload result:'; // At least one symbol should be sent to response!!!
$uploaddir = $_SERVER['DOCUMENT_ROOT']."/uploads/"; // path to images
makeMyDir($uploaddir );
if(count($_FILES) > 0) {
$arrfile = pos($_FILES);
$uploadfile = $uploaddir . basename($arrfile['name']);
if (move_uploaded_file($arrfile['tmp_name'], $uploadfile))
//FILE IS IN RIGHT DIRECTORY, START THE FUNKY IMAGE HANDLING NOW
$handle = new Upload($uploadfile);
$handle->file_new_name_body = strtotime("now");
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_x = 1024;
$handle->image_convert = 'jpg';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->process($uploadfile);
echo "File is valid, and was successfully uploaded.\n";
} else
echo 'No files sent. Script is OK!'; //Say to Flash that script exists and can receive files
echo 'Here is some more debugging info:';
print_r($_FILES);
Thanks for any help!
But apparently, there is a PHP wrapper for it here. In the cade there for PHP, it seems that it actually populates $_FILES.
In any case, with the class, you can process local files:
Wouldn't it be a solution?
Hmm, interesting on the local files approach, hadn't really looked at that. I guess I still wonder then at how to go through the files I've just uploaded with this module. This is the out of the box snippet that works:
So it's populating $_FILES as you say, but not with a named array (sorry, that's horribly wrong wording) like with your example: $_FILES['myfield']
You say it doesn't work yet. But does it work in some parts? What do you have working?
When you process the file, what $handle->log says?
Replace:
With:
You can do some logging like this:
And then open the file called log to see what the class does.
That was the issue all along, at least 50%. Updated to and it works like a charm -- as advertised.
Not sure I can effectively describe my shame at this moment...
Glad it works now.