debug($this->params);
On 4/20/06,
Helen Hoke <[EMAIL PROTECTED]> wrote:
I have a model called product. I would want to allow users to upload
images for each product. I found this script online:
http://www.blazonry.com/scripting/upload-size.phps
It works fine when it was uploaded outside cake. However I have a real
hard time making it to work on cake.
I created a view called upload_picture.thtml that contains the
following code:
<h1>Upload Product Picture</h1>
<form action="" echo $html->url('/products/uploadPicture')?>"
method="POST" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="25000">
Upload Image:
<input type="file" name="imgfile">
<font size="1">Click browse to upload a local file</font>
<input type="submit" value="Upload Image">
</form>
Then just for testing purpose, I added the following code in the
products_controller.php:
function _getFileExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
function uploadPicture($id = null){
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
/* SUBMITTED INFORMATION - use what you need
* temporary filename (pointer): $imgfile
* original filename : $imgfile_name
* size of uploaded file : $imgfile_size
* mime-type of uploaded file : $imgfile_type
*/
/*== upload directory where the file will be stored
relative to where script is run ==*/
$uploaddir = ".";
/*== get file extension (fn at bottom of script) ==*/
/*== checks to see if image file, if not do not allow upload ==*/
$pext = $this->_getFileExtension($imgfile_name);
$pext = strtolower($pext);
$this->flash('pext='.$pext,'/products');
}
else
{
$this->Product->id = $id;
}
}
I got the error message that
Notice: Undefined variable: imgfile_name
Is this sort of different environment setting?
I apologize for my extremely long post, and any idea or suggestion is
highly appreciated!
www.dospuntocero.info
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---
- need help uploading picture Helen Hoke
- Re: need help uploading picture Armando Sosa
- Re: need help uploading picture [EMAIL PROTECTED]