Sign in to follow this  

[web] Almost done with tumbnail upload on my website but I still have a small problem.

This topic is 2832 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So far what I've got is a window that pops up then the user selects the image to upload and presses the upload button, it uploads the image and is suppose to display it on the opener window but thats where I'm having problems, here is my source:
<?php
include 'random_string.php';
include 'file_extension.php';
$rand = randomString(10);
$target_path = "uploads/" . $rand .".". fileExtension( $_FILES['file']['name'] ); 
if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path))
{
echo('<script language = "JavaScript">');
echo('if (window.opener && !window.opener.closed)');
echo('{');
echo('var temp = new Image();');
echo('temp.src = "'.$target_path.'";');
echo('window.opener.document["thumbnail").src = temp.src;');
echo('}');
echo('window.close();');
echo('</script>');
}
else
{
echo('Unable to upload file, please try again.');
include('upload_image.php');
}
?>

Share this post


Link to post
Share on other sites
Not sure about the answer to your problem but I'd be very careful about letting people upload files without you validating them to some extent. Someone could upload a c99 script (google it if you don't know what it is) and have total control. If you let them specify the place to upload it too, a hacker could choose index.html and your index file is deleted for the hackers version!
Be careful...

Share this post


Link to post
Share on other sites
What's the problem you're having? What does move_uploaded_file do?

It looks like you're trying to upload a file to your server? I'm not sure what you're trying to do. You're running some code in javascript, but that's all client side stuff it looks like...

So yeah, not really sure what you're trying to do.

-me

Share this post


Link to post
Share on other sites
Quote:
Original post by Palidine
What's the problem you're having? What does move_uploaded_file do?

It looks like you're trying to upload a file to your server? I'm not sure what you're trying to do. You're running some code in javascript, but that's all client side stuff it looks like...

So yeah, not really sure what you're trying to do.

-me


Yes I think the javascript is the problem, mainly this code that should display the image on the main window but it just crashes, let me break it down to display the problem more clearly:

var temp = new Image();
temp.src = "image path";
window.opener.document["thumbnail").src = temp.src;

From a tutorial I read about updating images that should be the way to do it... I think...

Share this post


Link to post
Share on other sites

This topic is 2832 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this