blackrain87
09-14-2011, 06:09 PM
Hello there,
I have a little compact image upload page. The only problem with it is the image is not being passed through the form. I'm not sure why, I have used this same script before in multiple places, everything is the same, just doesn't work.
Here is the script side.
$current_image=$_FILES['image1']['name'];
$extension = substr(strrchr($current_image, '.'), 1);
if (($extension!= "jpg") && ($extension != "jpeg") && ($extension != "png"))
{
die('Restricted Extension, did not upload.');
}
$limit_size = 100000;
$file_size=$_FILES['image1']['size'];
if($file_size >= $limit_size)
{
die('Your file is too large, please pick a smaller file');
}
$time1 = date("fYhis");
$new_image = $time1 . "." . $extension;
$destination="images/".$new_image;
$action = copy($_FILES['image1']['tmp_name'], $destination);
if (!$action)
{
die('An error occured, please try again later.');
}
Here is the form
echo '<form name="upload" method="post" action="index.php?page=p_upload&action=upload">';
echo 'Picture Name: <input type=text" name="name"><br />';
echo 'File: <input type="file" name="image1"><br />';
echo 'Privacy Settings: <select name="privacy"><option value="Everyone">Everyone</option><option value="Friends">Friends Only</option><option value="Me">Only Me</option></select><br />';
echo '<input type="submit" value="Upload"></form>';
If anyone can point me in a direction to solving this, it will be much appreciated.
I have a little compact image upload page. The only problem with it is the image is not being passed through the form. I'm not sure why, I have used this same script before in multiple places, everything is the same, just doesn't work.
Here is the script side.
$current_image=$_FILES['image1']['name'];
$extension = substr(strrchr($current_image, '.'), 1);
if (($extension!= "jpg") && ($extension != "jpeg") && ($extension != "png"))
{
die('Restricted Extension, did not upload.');
}
$limit_size = 100000;
$file_size=$_FILES['image1']['size'];
if($file_size >= $limit_size)
{
die('Your file is too large, please pick a smaller file');
}
$time1 = date("fYhis");
$new_image = $time1 . "." . $extension;
$destination="images/".$new_image;
$action = copy($_FILES['image1']['tmp_name'], $destination);
if (!$action)
{
die('An error occured, please try again later.');
}
Here is the form
echo '<form name="upload" method="post" action="index.php?page=p_upload&action=upload">';
echo 'Picture Name: <input type=text" name="name"><br />';
echo 'File: <input type="file" name="image1"><br />';
echo 'Privacy Settings: <select name="privacy"><option value="Everyone">Everyone</option><option value="Friends">Friends Only</option><option value="Me">Only Me</option></select><br />';
echo '<input type="submit" value="Upload"></form>';
If anyone can point me in a direction to solving this, it will be much appreciated.