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.
IndexProgramming Questions & HelpOther Libraries › Post To Web Library v0.5 problem
Pages: 1 2 
Post To Web Library v0.5 problem (Read 4198 times)
Post To Web Library v0.5 problem
May 14th, 2010, 3:28pm
 
I'm new to Processing.  I'm trying to use the Post to web library and having issues. I'm using the supplied example:
Quote:
import processing.pdf.*;
import org.seltar.Bytes2Web.*;
PDFToWeb pdf;

void setup()
{
  size(800,600);
  pdf = new PDFToWeb(this);
}


void draw()
{
  background(0);
  stroke(255);
  line(random(width),random(height),random(width),random(height));
  pdf.addPage(); // if you want each frame to be on it's own page
}

void keyPressed()
{
  String url = "http://itsshameful.com/";
  if(key == 'p'){
    if(!pdf.isRecording()){
      pdf.startRecording();
    }else{
      pdf.save("pdf");
      pdf.post("test",url,"pdf-test",true);
    }
  }
  if(key == 'j'){
    ImageToWeb img = new ImageToWeb(this);
    img.save("jpg",true);
    img.post("test",url,"jpg-test",true,img.getBytes(g));
  }
  if(key == 't'){
    ImageToWeb img = new ImageToWeb(this);
    img.setType(ImageToWeb.TIFF);
    img.save("tiff",true);
    img.post("test",url,"tiff-test",true);
  }
  if(key == 'n'){
    ImageToWeb img = new ImageToWeb(this);
    img.setType(ImageToWeb.PNG);
    img.save("png",true);
    img.post("test",url,"png-test",true);
  }
  if(key == 'g'){
    ImageToWeb img = new ImageToWeb(this);
    img.setType(ImageToWeb.GIF);
    img.save("gif",true);
    img.post("test",url,"gif-test",true);
  }
}



itsshameful.com is a live site with only two things in the root directory..a folder named saved and the file Upload.php as per the instructions.  the folder "saved" is 777.  I'm getting these errors:

KEY PRESSED....P



Exception in thread "Animation Thread" java.lang.NoClassDefFoundError: processing/pdf/PGraphicsPDF
     at java.lang.ClassLoader.defineClass1(Native Method)
     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
     at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
     at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
     at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
     at processing.core.PApplet.makeGraphics(Unknown Source)
     at processing.core.PApplet.createGraphics(Unknown Source)
     at org.seltar.Bytes2Web.PDFToWeb.startRecording(PDFToWeb.java:26)
     at example_1.keyPressed(example_1.java:47)
     at processing.core.PApplet.handleKeyEvent(Unknown Source)
     at processing.core.PApplet.dequeueKeyEvents(Unknown Source)
     at processing.core.PApplet.handleDraw(Unknown Source)
     at processing.core.PApplet.run(Unknown Source)
     at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: processing.pdf.PGraphicsPDF
     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
     ... 21 more

KEY PRESSED.....J











java.io.FileNotFoundException: http://itsshameful.com/
     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1311)
     at org.seltar.Bytes2Web.PostToWeb._post(PostToWeb.java:108)
     at org.seltar.Bytes2Web.ImageToWeb.post(ImageToWeb.java:73)
     at example_1.keyPressed(example_1.java:56)
     at processing.core.PApplet.handleKeyEvent(Unknown Source)
     at processing.core.PApplet.dequeueKeyEvents(Unknown Source)
     at processing.core.PApplet.handleDraw(Unknown Source)
     at processing.core.PApplet.run(Unknown Source)
     at java.lang.Thread.run(Thread.java:619)
java.io.FileNotFoundException: http://itsshameful.com/
     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1311)
     at org.seltar.Bytes2Web.
Re: Post To Web Library v0.5 problem
Reply #1 - May 15th, 2010, 1:23am
 
I get a "Error 403 - Forbidden" error if I try and access http://itsshameful.com/ site (you should put at least a generic index.html page, perhaps) and if I try to access http://itsshameful.com/Upload.php I get the source code of the page (curiously with syntax highlighting) which might show that PHP isn't activated on this server.
Re: Post To Web Library v0.5 problem
Reply #2 - May 15th, 2010, 11:58am
 
My service provider is 1and1.com, they use PHP 5.  I run PHP on other sites there.  I didn't put an index page, because I didn't want any distraction....only the code I'm working on, in the folder.

One of the things that disturbed me is that the file Upload.phps seems to be html rather than PHP.  That's why it comes up as formatted code.
Re: Post To Web Library v0.5 problem
Reply #3 - May 15th, 2010, 12:21pm
 
The problem, however, is this........why can't the sketch find the file?
Re: Post To Web Library v0.5 problem
Reply #4 - May 15th, 2010, 12:46pm
 
Now I'm really confused.  I took your advice and uploaded an index file. Now I get this error message:










java.io.IOException: Server returned HTTP response code: 405 for URL: http://itsshameful.com/
     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1313)
     at org.seltar.Bytes2Web.PostToWeb._post(PostToWeb.java:108)
     at org.seltar.Bytes2Web.ImageToWeb.post(ImageToWeb.java:73)
     at example_1.keyPressed(example_1.java:56)
     at processing.core.PApplet.handleKeyEvent(Unknown Source)
     at processing.core.PApplet.dequeueKeyEvents(Unknown Source)
     at processing.core.PApplet.handleDraw(Unknown Source)
     at processing.core.PApplet.run(Unknown Source)
     at java.lang.Thread.run(Thread.java:619)
Re: Post To Web Library v0.5 problem
Reply #5 - May 16th, 2010, 3:57am
 
Robert wrote on May 15th, 2010, 11:58am:
One of the things that disturbed me is that the file Upload.phps seems to be html rather than PHP.  That's why it comes up as formatted code.

Ah, indeed, if I save the file from the provided link, I get the colored HTML page. That's a problem.
A quick fix is to click on the link, hit Ctrl+A then Ctrl+C to copy the whole code and paste it in a plain text editor in the Update.php file.
Re: Post To Web Library v0.5 problem
Reply #6 - May 16th, 2010, 9:00am
 
i've got the same problem...

Code:
import processing.pdf.*;
import org.seltar.Bytes2Web.*;
PDFToWeb pdf;

void setup()
{
size(800,600);
pdf = new PDFToWeb(this);
}


void draw()
{
background(0);
stroke(255);
line(random(width),random(height),random(width),random(height));
pdf.addPage(); // if you want each frame to be on it's own page
}

void keyPressed()
{
String url = "http://www.wollle.com/savetoweb/";
if(key == 'p'){
if(!pdf.isRecording()){
pdf.startRecording();
}else{
pdf.save("pdf");
pdf.post("test",url,"pdf-test",true);
}
}
if(key == 'j'){
ImageToWeb img = new ImageToWeb(this);
img.save("jpg",true);
img.post("test",url,"jpg-test",true,img.getBytes(g));
}
if(key == 't'){
ImageToWeb img = new ImageToWeb(this);
img.setType(ImageToWeb.TIFF);
img.save("tiff",true);
img.post("test",url,"tiff-test",true);
}
if(key == 'n'){
ImageToWeb img = new ImageToWeb(this);
img.setType(ImageToWeb.PNG);
img.save("png",true);
img.post("test",url,"png-test",true);
}
if(key == 'g'){
ImageToWeb img = new ImageToWeb(this);
img.setType(ImageToWeb.GIF);
img.save("gif",true);
img.post("test",url,"gif-test",true);
}
}


evokes this error:

Code:
java.io.FileNotFoundException: http://www.wollle.com/savetoweb/
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at org.seltar.Bytes2Web.PostToWeb._post(PostToWeb.java:108)
at org.seltar.Bytes2Web.PostToWeb._post(PostToWeb.java:67)
at org.seltar.Bytes2Web.ImageToWeb.post(ImageToWeb.java:65)
at savetoweb.keyPressed(savetoweb.java:65)
at processing.core.PApplet.handleKeyEvent(PApplet.java:1747)
at processing.core.PApplet.dequeueKeyEvents(PApplet.java:1730)
at processing.core.PApplet.handleDraw(PApplet.java:1435)
at processing.core.PApplet.run(PApplet.java:1328)
at java.lang.Thread.run(Unknown Source)


somebody knows qhat to do?
Re: Post To Web Library v0.5 problem
Reply #7 - May 16th, 2010, 9:11am
 
when storing an empty index.html file in the folder i get this error:

Code:
java.lang.StringIndexOutOfBoundsException: String index out of range: 4
at java.lang.String.substring(Unknown Source)
at org.seltar.Bytes2Web.PostToWeb._post(PostToWeb.java:127)
at org.seltar.Bytes2Web.PostToWeb._post(PostToWeb.java:67)
at org.seltar.Bytes2Web.ImageToWeb.post(ImageToWeb.java:65)
at savetoweb.keyPressed(savetoweb.java:65)
at processing.core.PApplet.handleKeyEvent(PApplet.java:1747)
at processing.core.PApplet.dequeueKeyEvents(PApplet.java:1730)
at processing.core.PApplet.handleDraw(PApplet.java:1435)
at processing.core.PApplet.run(PApplet.java:1328)
at java.lang.Thread.run(Unknown Source)
Re: Post To Web Library v0.5 problem
Reply #8 - May 16th, 2010, 10:36am
 
Ah, I see, the ambiguity in the given example is in the line:
String url = "YOUR URL HERE";
It must be read:
String url = "http://www.yoursite.com/sketchName/Upload.php";
for example, ie. you must specify the PHP script to target in the URL.
Re: Post To Web Library v0.5 problem
Reply #9 - May 16th, 2010, 12:26pm
 
I made the changes and things look better....however.

I don't get any error messages, the files are saved locally and I can see web activity, but the images are NOT being saved to my web space, and I don't know why.  The sketch is obviously talking to the server, the folder is 777 but the files don't make it there.

Also, I want to thank you for your help.  To spend your valuable time helping others is incredible...you make the world better.
Re: Post To Web Library v0.5 problem
Reply #10 - May 16th, 2010, 3:33pm
 
Thanks, Robert, I actually enjoy the little intellectual challenges I meet in this forum... and I like to help, too! Smiley

You might want to change the line setting $destDir. In my original code, I set it to '../Uploads' ie. in an "Uploads" dir at same level than the folder where the Upload.php file is. In Seltar's version, it is 'saved/'.$title.'/' although I haven't guessed what $title is supposed to be here.
Set it to a path convenient for you, and with write access from the PHP script.
Re: Post To Web Library v0.5 problem
Reply #11 - May 17th, 2010, 4:04pm
 
I'm sorry to be such a pest, I just can't make it work.  When I export as an applet it won't even save locally.  It's driving me crazy.

You mentioned your original code.  I tried to find it, but it's no longer available.  Would you share a copy?
Re: Post To Web Library v0.5 problem
Reply #12 - May 18th, 2010, 2:14am
 
See Re: save to web --- image export

The problem is that so many things can go wrong if not correctly parametrized, it is hard to help without being in place... Smiley
Re: Post To Web Library v0.5 problem
Reply #13 - May 19th, 2010, 11:54am
 
I got it to work.
I took this out on line 175 of the PHP file:
$files = @scandir($destDir);
I don't know why it was a problem, but it was.
Re: Post To Web Library v0.5 problem
Reply #14 - May 19th, 2010, 11:57am
 
PhiLho  wrote on May 18th, 2010, 2:14am:

It appears to be gone...
" - Unknown paste ID, it may have expired or been deleted!"
Pages: 1 2