Hey there, thank you so much for replying, this is still really doing
my head in!

Thanks for the suggestions, that helped :) It's not really an ajax
call though. The JS creates an invisible iframe to submit the form
into, the php uploads the file and then returns some html with the img
src in it which gets copied into the main document by the JS.

I've got a bit futher now and I'm getting results returned back, so
the onchange is working, the php upload bit isn't though. I'm having
trouble figuring out where different things should go.

In the default version of the scripts, the onchange does it's thing in
JS and eventually passes a bunch of parameters to a php file to
process the upload. The problem parameter looks like:
'upload.php?
filename=name&maxSize=9999999999&maxW=500&fullPath=http://
localhost/sponster/app/webroot/uploads/&relPath=../uploads/
&colorR=255&colorG=255&colorB=255&maxH=800'

How to call this file within cakephp is my problem, Cake wants there
to be a controller function. So... in the php file there's a upload
function which processes the file and then underneath there's some
code doing: $filename = strip_tags($_REQUEST['filename']); to the
parameters which were sent before calling the upload function.

I tried to split it up into two functions, one which the JS calls (and
which then calls the upload function) but that didn't work. It's how
to split up the code I can't figure out. Is it not possible to un-
cakify things and just open a php file?

Once again, I appreciate your help :)




On Nov 17, 11:04 am, phpMagpie <[email protected]> wrote:
> Barricades,
>
> The idea of firing of an ajax request (which means your existing page does
> not get reloaded) to upload a file and have the files path returned is
> relatively simple and I'm sure you will be able to modify any of the
> existing plugins to do this, you just need to get a grip on how to use
> javascript and what happens when you fire an ajax call.
>
> What you need to be able to do is debug what's happening with your script.
>
>    1. Is the js file being loaded?
>    2. Is the onChange event bring triggered? (try a simple alert('The field
>    has changed');)
>       1. If so, is it then firing an ajax call to your controller/action
>          1. At this point you should be using FireBug or something similar
>          to see what the ajax request is sending and receiving, but all you 
> want is
>          for your controller action to process the file and send back the 
> image's
>          url (which all decent upload scrips should make available)
>
> HTH, Paul

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to