Hi, I'm making a simple image upload site but I know very little PHP coding and was wondering whether any of you guys could help.
If you take a look at this link hopefully you'll be able to see what I'm trying to do closer, http://swiftsnap.skiroid.com/.
It all works well expect for I want the green or red notification box to replace the blue one instead of appearing underneath it.
Here is the code I've got at the moment. If you need to change the structure altogether please do.
I would appreciate any help. Thanks.
If you take a look at this link hopefully you'll be able to see what I'm trying to do closer, http://swiftsnap.skiroid.com/.
It all works well expect for I want the green or red notification box to replace the blue one instead of appearing underneath it.
Here is the code I've got at the moment. If you need to change the structure altogether please do.
PHP Code:
<?php
echo "
<div id='notification-ok'>
<div id='notification-image'>
<img src='images/ok.png' width='100' height='100' />
</div>
<p id='notification-title'><strong>Pick your image to share.</strong></p>
<p>Swift Snap offers you a quick and easy service. All you have to do is choose an image you'd like to upload and you'll have the link to share it within seconds!</p>
</div>
";
if ($_POST['uploadbutton']) {
$name = $_FILES['picture']['name'];
$type = $_FILES['picture']['type'];
$tmpname = $_FILES['picture']['tmp_name'];
$charset = 'abcdefghijklmnopqrstuvwxyz0123456789';
$length = 15;
$ext = substr($name, strrpos($name, '.'));
if (strstr($type, "image")) {
for ($i = 0; $i <= $length; $i++) {
$rand = rand() % strlen($charset);
$tmp = substr($charset, $rand, 1);
$code .= $tmp;
}
while ($numrows != 0) {
for ($i = 0; $i <= $length; $i++) {
$rand = rand() % strlen($charset);
$tmp = substr($charset, $rand, 1);
$code .= $tmp;
}
}
move_uploaded_file($tmpname, "pictures/".$code.$ext);
echo "
<div id='notification-yes'>
<div id='notification-image'>
<img src='images/yes.png' width='100' height='100' />
</div>
<p id='notification-title'><strong>Your image is ready to share!</strong></p>
<p>Your image has been uploaded to:<br><a href='http://swiftsnap.skiroid.com/pictures/$code$ext' target='_blank'>swiftsnap.skiroid.com/pictures/$code$ext</a></p>
</div>
";
}
else
echo "
<div id='notification-no'>
<div id='notification-image'>
<img src='images/no.png' width='100' height='100' />
</div>
<p id='notification-title'><strong>Unable to upload your file.</strong></p>
<p>You have either chosen a file which is not an image or you havn't chosen a file at all. You can only upload images to Swift Snap.</p>
</div>
";
}
?>

Comment