Jump to content

Recommended Posts

Currently im using the following script in an attemp to preview local images before submitting them but it doesnt change...

[code]
        <tr><td class="text">Image:</td>
            <td><img id="icon" class="world">
                <input type="hidden" name="MAX_FILE_SIZE" value="5000" /><input type="file" name="char_pic" size="15" class="char_pic" onclick="icon.src = 'file:///' + this.value" /></td></tr>
[/code]

does anyone know why? the file exists...
Link to comment
https://forums.phpfreaks.com/topic/21735-preview-local-images/
Share on other sites

hey, cool. it works.

problem is the onClick. Clicking the button opens the browse window while the javascript attempts to load an unselected image to the image source. After you select a picture, click it again and the image pops right up.

maybe onclick isn't the right way to do this? maybe a <body onFocus> or something?
Link to comment
https://forums.phpfreaks.com/topic/21735-preview-local-images/#findComment-97107
Share on other sites

hrm body focus doesnt work out for me just due to the theme script which goes basicly like...

<html>
<body>
{MAIN}
</body>
</html>

where {MAIN} is it loads all the info into. so yeah... accessing body easily doesnt work very well. ;)

i changed it to onChange... doesnt work
Link to comment
https://forums.phpfreaks.com/topic/21735-preview-local-images/#findComment-97745
Share on other sites

What about a setInterval that checks this.value for a value every three or five seconds. Onclick starts the setInterval, and the function called by setInterval will assign the image source and unset the interval upon finding a value?
Link to comment
https://forums.phpfreaks.com/topic/21735-preview-local-images/#findComment-97754
Share on other sites

[code=php:0]var my_var = setInterval("somefunction",5000);[/code]

That would fire the function every five seconds.

http://developer.mozilla.org/en/docs/DOM:window.setInterval
http://developer.mozilla.org/en/docs/DOM:window.clearInterval

[b]PS>[/b] it is case sensitive and firefox is very very case sensitive. Also, the quotes aren't listed in the manuel, however, I found that firefox wouldn't work without quoting the function to call.
Link to comment
https://forums.phpfreaks.com/topic/21735-preview-local-images/#findComment-97761
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.