Archive for the ‘Tech’ Category

RJ’s interesting Form data problem

Sunday, November 22nd, 2009

 AJAX file upload tutorial

So I was trying to figure out how I could upload a file without refreshing the page for a form that I am creating and boy was it a pain. I found this post here (http://www.ajaxf1.com/tutorial/ajax-file-upload-tutorial.html) that allowed me to do the file upload part without refreshing the page. I was ecstatic and thankful to Ajaxf1 when I got it to work.

It is worthwhile to mention that although this comes from a website called ajaxf1 the way that he/she does this upload does not use Ajax it loads the action of the upload form in a hidden iframe not using the xmlhttp object.

But unfortunately my joy was short lived. I soon noticed that I didn’t know how to get the URL of the uploaded image into my form data that would eventually go into my database. After some time lamenting and 2 hours of banging my head against the wall I discovered a very simple solution, shockingly simple actually. I have posted it here because I haven’t seen it anywhere else.

in the upload.php file which can be found at the link above you just change the call to the javascript function like so:

<?php

echo(‘<script language="javascript" type="text/javascript">
window.top.window.stopUpload(‘.$result.’,"’.$target_path.’");
</script>’)

?>

$result is success or not and $target_path is the URL of the uploaded image. Then modify the stopUpload function like so:

function stopUpload(success, pic){
      var result = "";
      if (success == 1){
      document.getElementById("result").innerHTML = "<span class=’msg’>The file was uploaded successfully!</span><br/><br/>";
        document.getElementById("hiddenpic").value = pic;
        }
         else
        {
        document.getElementById("result").innerHTML = "<span class=’emsg’>There was an error during file upload!</span><br/><br/>";
                }
        document.getElementById("f1_upload_process").style.visibility = "hidden";
        return true;
        }

What this ends up doing is that if success = 1 it modifies a hidden field in my form called hiddenpic with the URL of the uploaded image, which was passed into the formula in upload.php.

Oh one other interesting thing is that you cannot nest form tags. If you place the file upload form within your original form clicking upload on the form will submit the form that the upload form is nested within.

If you want it to look as though the upload form is part of the original form you will have to do some fancy css placement tricks.

Hopefully one day someone will find this useful. For the entire explanation of the whole “Ajax”( although it is not really Ajax) upload process go to the original site here.

Peace out ya’ll! hopefully this was not that boring of a read haha.

RJ is so embarrassed!

Monday, July 27th, 2009

So remember all my rantings about the iPhone and how the palm pre was better? Well I was somewhat correct and somewhat incorrect. The software on the Palm Pre is WAY better, I mean WAY better. But the iPhone hardware is way better than the Palm Pre. So long story short I now have an iPhone 3G S. Your probably thinking “but you hat iTunes so much! what do you hate more than iTunes?” Well I’ll tell you!

I was willing to deal with my single stuck pixel, I was willing to deal with the short battery life, and I even would have been able to deal with the lack of visual voice mail. But all of these combined with the iffy hardware forced me to go back to the iPhone. Ugh… I am so upset. But what could I do? I heard so many bad things about the hardware! One of my friend’s phones randomly restarts when it is shaken, and half of the people I know who have pre’s have stuck pixels! I just can’t deal with that kind if problematic hardware especially since it is so important that I stay connected.

But now… I am stuck with the iPhone. All I can do is one task at a time, it sucks. It is a pain in the ass. But at least this phone has a respectable battery life and is not extremely sluggish when opening apps and what not.

The Palm Pre was just not ready to be released. The software us complete enough and I would say better than the iPhone’s by leaps and bounds but the hardware I think is more important when you compare the iPhone and Pre. Because the iPhone is still very functional and has complete and good hardware.

So now I am done rationalizing! Peace out ya’ll!!

Oh and by the way this was written on an iPhone 3G S.

Palm Pre OS 1.1.0

Friday, July 24th, 2009

So yesterday I got a text message from one of my friends saying that the palm pre OS 1.1.0 was out. Unfortunately I was nowhere near any sort of wifi network so I, of course, downloaded over the EVDO network. 10% of my battery life and 30 minutes later I had finished downloading the 1.1.0 update. When I installed it I was very pleasantly surprised. I noticed two things. First the phone seems to have gotten a little bit faster after the update (but this could be in my head). And second now the browser on the phone supports CSS opacity.

I could not understand why the browser didn’t support CSS opacity but now I know. The browser was not complete yet. I wonder if it is completed now haha. But in any event install the 1.1.0 update went smoothly and there were noticeable improvements in the device.

That’s all for now folks.

Peace out!