Lots of Frustrations but I’ve made a breakthough…
But I’m still behind. It’s terrible feeling like you’re in a ditch, and I got myself into one, and this isn’t a pity party I’m just saying that I’ve been working hard lately but I was feeling like I was getting nowhere until about 10 this morning. I was and am behind on my first project because it was a little beyond me once I got to the php, and until I crossed that bridge, I wasn’t making progress with either project 1 or 2. Project 2 is a simple extension of my first project. We did some image upload labs in class which were a breeze, so I decided to allow users to not only comment on my pieces, but also upload their own.
It all seemed simple enough, because I already had php writing jpeg data to a browser. I was wrong. Saving the jpeg to the browser was one line of php.
imageJPEG($image , “”, 80);
The first parameter is my actual bitmap data that I passed in, the second is a file location, and if its left as null or blank, it outputs the image to the browser. The third parameter is simply a quality number, and after some tests I realized the difference between 80 and 100 negligable, and it made a difference between file sizes of 12kb VS 50kb. If I can load 4 images that look the same in the same time that it takes me to load one image that looks the same, but is theoretically better quality, then I’m all for faster load times.
I needed to save the images to a directory though, not just the browser. Simple enough, specify the location in the pathname parameter in the imageJpege() function. But this didn’t work. I tried various naming conventions but I got no result. After my professor Jason and I looked at it last week he thought it looked correct and pegged it off to file permissions. I thought that was great because I didn’t remember if I actually had set the permissions on the parent directory of the directory where images would be stored. Sure enough I hadn’t but after fixing it it still wasn’t uploading pictures (nor showing them in the browser for that matter.) So I changed the permissions on everything I could think would have a possible that might inhibit php from saving an image to RIT’s server, but still it wasn’t working. After another suggestion from Jason I tried uploading the project to a friends server, because maybe it was something with administrative permissions on RIT’s server. Once again, I had no luck. The code was currently:
imagejpeg($image, “./media/test1.jpeg”,80);
I tried using fwrite(). I tried putting everything in a true color image first. I tried other file format functions, but still I got nothing. I was stuck in a rut and couldn’t move forward because I didn’t know what to do if I couldn’t draw stuff from my database, so I kept testing until one of my friends, Colin Doody said he might be able to help. I had to wait a day to get his help, but I was sure he would be able to help. So yesterday afternoon after class, I met up with Colin and showed him my AS, my php, and the swf Test I had online. Then he asked me to show him the directory where I was trying to store the images. Sure enough, when I open the directory I see “test1.jpeg” and the getInfo in fetch revealed it had been created a minute before. Now I have no idea what happened because when I last checked on Monday, nothing was writing to that directory. The only thing I can think of is when there was a storm on Monday, a transformer blew, and a good portion of RIT lost power. I also know that the whole CIAS server went down. So maybe that had something to do with it? I don’t really know, but the code started working, as it should have in the first place. After an all-nighter I now have each image getting saved with a unique name to my specified directory, and a pathname to each image is getting uploaded to my database. Php creates xml on the fly passing in a unique id and the file path for each image in individual nodes.
I’m not a whiz with php, I’d like to be, but its still a little confusing. I’ll get a good grip on it soon enough. I can’t just copy and paste sample code or lab code without understanding everything its doing. Most everything that is, because otherwise I’ll never be able to do it on my own. So now that I finally understand everything that everything else is doing, I’ve made a commitment to myself that these projects will be finished in the next 24 hours. I know what I’m doing, I understand everything, and all of the complicated coding is over. Like I said there have been a lot of frustrations over the past week, and even just this quarter in a general, but I really feel good now. But I’m still behind. And that ends today.














