We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Pages: 1 2 
post2web error (Read 7102 times)
post2web error
Jun 8th, 2010, 10:25pm
 
Hi, i am using seltars post2web library to upload images and hopefully other files ( txt in this case) http://libraries.seltar.org/postToWeb/
i made all the mentioned steps above but still get the following error.


java.lang.StringIndexOutOfBoundsException: String index out of range: 4
     at java.lang.String.substring(String.java:1934)
     at org.seltar.Bytes2Web.PostToWeb._post(PostToWeb.java:127)
     at org.seltar.Bytes2Web.ImageToWeb.post(ImageToWeb.java:73)
     at example_1.keyPressed(example_1.java:47)
     at processing.core.PApplet.handleKeyEvent(PApplet.java:1752)
     at processing.core.PApplet.dequeueKeyEvents(PApplet.java:1735)
     at processing.core.PApplet.handleDraw(PApplet.java:1437)
     at processing.core.PApplet.run(PApplet.java:1327)
     at java.lang.Thread.run(Thread.java:619)


does anybody have an idea what that could be. i believe i did everything that was necessary. There is nothing to change in the Upload.php, right?

Re: post2web error
Reply #1 - Jun 9th, 2010, 1:27am
 
With the full stack trace, I can answer...
The faulty line is:
if(responseLine.substring(0,4).equals(("http").substring(0,4))){
where responseLine is the string sent by the server after giving an HTTP 200 (OK) answer.
The problem is that the code takes a substring of this line without first checking the length of the string...
I don't know what is returned by your server (my Upload.php is supposed to return an HTML fragment) but it is too short (perhaps empty).

Note that Upload.php isn't part of postToWeb library, so there is no guarantee that they work correctly together.
Re: post2web error
Reply #2 - Jun 9th, 2010, 1:42am
 
i am using the Upload.php that seltar offers at the library page
http://libraries.seltar.org/postToWeb/

http://libraries.seltar.org/postToWeb/Upload.phps

so i thought they do work together...
Re: post2web error
Reply #3 - Jun 9th, 2010, 2:31am
 
Ah, OK, it is a slightly modified version of mine, which indeed returns an URL if everything went OK, and should return an error message otherwise.
Perhaps something goes wrong in the PHP run so nothing is returned although I wonder why a code 200 is returned, in this case...

Note you have to either change the PHP script (the $destDir, the 'portfolio' name) or to fit to the given folder scheme...
Re: post2web error
Reply #4 - Jun 9th, 2010, 3:04am
 
i actually thought i did that by creating a "saved" folder as mentioned.
but i found the "porfolio" variable and was wondering what that might be as it is not mentioned anywhere. Could you tell me what that is and where it is used. maybe thats where the problem is.

Re: post2web error
Reply #5 - Jun 9th, 2010, 5:23am
 
If the Web server is http://www.example.com, the returned URL will be:
http://www.example.com/portfolio/saved/test/ImageName.png
where "test" is the first parameter of post() call and ImageName.png is whatever is created... (if I understood correctly the various parts).
Both the sketch files and the Upload.php file must be in the 'portfolio' folder.
Re: post2web error
Reply #6 - Jun 9th, 2010, 6:46am
 
hmm. i moved the Upload.php to http://domain.com/portfolio/
in there i created another folder called saved, and in the saved folder a test folder. Not sure if thats the way it is supposed to be.

and i dont know what you mean by sketch files in this case
Quote:
Both the sketch files and the Upload.php file must be in the 'portfolio' folder.
Re: post2web error
Reply #7 - Jun 9th, 2010, 7:03am
 
The sketch files are the exported files (HTML and jar).
Of course, you can change the 'portfolio' part to any name, as long as you change it in the PHP file. Same for 'test' in your PDE file.
Re: post2web error
Reply #8 - Jun 9th, 2010, 7:14am
 
ah ok, i see.  there was a misunderstanding and maybe the reason for the problem. i run this sketch locally. i dont want to use it online, i just need to upload the files.
Re: post2web error
Reply #9 - Jun 9th, 2010, 7:58am
 
Use FTP!  Tongue  Grin

Just joking, of course, I understand it can be practical do to this in real time, automatically.
Re: post2web error
Reply #10 - Jun 9th, 2010, 8:27am
 
yes,i believe it is better to keep it local as i need to compute some files stored on my computer and the webcam as well...

i dont have any problems with your Upload sketch example though. i run it in the processing ide on my pc and the upload works great. So can you see where the problem might be in seltars example sketch or php File ?
Re: post2web error
Reply #11 - Jun 9th, 2010, 9:25am
 
So, what is your exact setting, now?
Re: post to web error
Reply #12 - Jun 9th, 2010, 9:54am
 
so for now, i am just trying to use seltars post to web library. Although it is based on your example and your example seems to work. i am not using any of your files for now.

right now i am using the example sketch, that comes with the library. you can see the source of this sketch here : http://libraries.seltar.org/postToWeb/

i did all the mentioned steps. especially these :

...
5. Upload this php file to your server: Upload.phps, and rename it to Upload.php
6. Create a folder called "saved" in the folder where you put Upload.php
7. Set write permissions on that folder (chmod 0777)

the file is now at http://www.example.com/Upload.php.
There is a folder at http://www.example.com/saved

in the PDE i changed the String to
String url = "http://www.example.com";

and i am running the sketch locally.
i didnt change anything in the PHP file as it wasnt mentioned on the Libraries page and i believe it is not necessary if i name the folder "saved" If i am wrong please correct me.

i also created a folder called "test" in the saved folder.
and i tested both.
http://www.example.com/saved/test
http://www.example.com/portfolio/saved/test
Re: post to web error
Reply #13 - Jun 9th, 2010, 2:03pm
 
Cedric wrote on Jun 9th, 2010, 9:54am:
5. Upload this php file to your server: Upload.phps, and rename it to Upload.php

I recall you had issues with this one. If you open the PHP file, you have PHP code, right Not HTML code (since the page was syntax highlighted...).

And if I am not mistaken, the PHP file must be one folder above 'saved', not inside it.
Re: post2web error
Reply #14 - Jun 9th, 2010, 2:31pm
 
thx PhiLo for figuring that out. that was definitely one of the issues. i downloaded the php file using "save as" without taking a look at it and uploaded it to the server, but you are right, it is actually html . But i copy and pasted the code into a new Upload.php and uploaded it now...

Quote:
And if I am not mistaken, the PHP file must be one folder above 'saved', not inside it.

yes, that's how i did it...
the "saved" folder and the php file are both in the same folder.
maybe my explanation was misleading.

so now as i uploaded the new php its still not working ( same error)
i am pretty sure there is just one little mistake of setting up the folders or a variable. but i cant figure out what that might be.
Pages: 1 2