PDA

View Full Version : Uploader Problem



Rockstar
03-10-2007, 07:45 PM
Ok im making a Uploader for a Friend.
http://www.twoupload.com/uploader.php (http://www.twoupload.com/uploader.php)
Ok uploads fine but he redirect dosent work.
Upload and see!
Could you hep me with this

Eccentric
03-10-2007, 07:47 PM
post the code, don't think you have set the $_get eg up or u dont have the file upload.php

Rockstar
03-10-2007, 07:51 PM
post the code, don't think you have set the $_get eg up or u dont have the file upload.php
<?
// Script Made By Ashley Cusack
// CONFIG
$siteurl = "http://www.twoupload.com"; //Must Include http:// and www. ending in where the images upload to with NO trailing slash
$serverpath = "images/"; // The End of the part above
$urltoimages = "$siteurl"; // Web address to where the images are accessible from.
$maxsize = "10000"; // Maximum size of the file people can upload
$uniq = uniqid("");
// CONFIG END
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='upload.php?mode=upload'>\n";
echo "Upload file: <input type='file' name='file'>\n";
echo "<br><input type='submit' name='Submit' value='Upload'>\n";
$bytesize = "1000";
$kb = $maxsize/$bytesize;
echo "<br>Maximum File Size: $kb Kilobytes <em>($maxsize Bytes)</em>";
}
if ($mode == "upload") {
$file = $_FILES['file']['name'];
$name = time() . substr($file, -4);
// If you add your own file types don't forget to add an uppercase version.
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "jfef";
$allowedfiles[] = "jpe";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "JFEF";
$allowedfiles[] = "JPE";
$allowedfiles[] = "PNG";
$allowedfiles[] = "PDF";
$allowedfiles[] = "pdf";
$allowedfiles[] = "PSD";
$allowedfiles[] = "psd";
$allowedfiles[] = "bmp";
$allowedfiles[] = "BMP";
$allowedfiles[] = "tif";
$allowedfiles[] = "tiff";
$allowedfiles[] = "TIF";
$allowedfiles[] = "TIFF";
$allowedfiles[] = "dib";
$allowedfiles[] = "DIB";
$allowedfiles[] = "sql";
if($_FILES['file']['size'] > $maxsize)
{
print "File size is too big - please reduce file size and try again.";
}
else {
$path = "$serverpath/" . $name;
foreach($allowedfiles as $allowedfile) {

if ($done <> "yes") {
if (file_exists($path)) {
echo "A file with this name already exists - please rename the file and reupload.";
exit;
}
}

if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</p>";
echo "<p>Please Note we do not take any responsibility of the images that you upload</p>";
?>
<!-- All the kinds of code you want to be outputed go here -->
<img src="<?php echo "$urltoimages/$name" ?>">
<br>Direct Link: <input name='direct' type='text' align='center' size='70' value='<?php echo "$urltoimages/$name" ?>'>
<br> BB Code:<input name='bbcode1' type='text' align='center' size='70' value=''>
<br> BB Code: <input name='bbcode2' type='text' align='center' size='70' value='[img]<?php echo "$urltoimages/$name" ?>'>
<!-- End of all HTML Code -->
<?php

}
}
if ($done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
}
}
?>

I havent set the redirect up Yet because didnt know how!

Eccentric
03-10-2007, 07:56 PM
ok O.o

echo "<form enctype='multipart/form-data' method='post' action='upload.php?mode=upload'>\n"; that is the line you need sir. :)

Rockstar
03-10-2007, 07:57 PM
ok O.o

echo "<form enctype='multipart/form-data' method='post' action='upload.php?mode=upload'>\n"; that is the line you need sir. :)
Where do I put that

Eccentric
03-10-2007, 07:58 PM
try;

<?
// Script Made By Ashley Cusack
// CONFIG
$siteurl = "http://www.twoupload.com"; //Must Include http:// and www. ending in where the images upload to with NO trailing slash
$serverpath = "images/"; // The End of the part above
$urltoimages = "$siteurl"; // Web address to where the images are accessible from.
$maxsize = "10000"; // Maximum size of the file people can upload
$uniq = uniqid("");
// CONFIG END
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='uploader.php?mode=upload'>\n";
echo "Upload file: <input type='file' name='file'>\n";
echo "<br><input type='submit' name='Submit' value='Upload'>\n";
$bytesize = "1000";
$kb = $maxsize/$bytesize;
echo "<br>Maximum File Size: $kb Kilobytes <em>($maxsize Bytes)</em>";
}
if ($mode == "upload") {
$file = $_FILES['file']['name'];
$name = time() . substr($file, -4);
// If you add your own file types don't forget to add an uppercase version.
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "jfef";
$allowedfiles[] = "jpe";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "JFEF";
$allowedfiles[] = "JPE";
$allowedfiles[] = "PNG";
$allowedfiles[] = "PDF";
$allowedfiles[] = "pdf";
$allowedfiles[] = "PSD";
$allowedfiles[] = "psd";
$allowedfiles[] = "bmp";
$allowedfiles[] = "BMP";
$allowedfiles[] = "tif";
$allowedfiles[] = "tiff";
$allowedfiles[] = "TIF";
$allowedfiles[] = "TIFF";
$allowedfiles[] = "dib";
$allowedfiles[] = "DIB";
$allowedfiles[] = "sql";
if($_FILES['file']['size'] > $maxsize)
{
print "File size is too big - please reduce file size and try again.";
}
else {
$path = "$serverpath/" . $name;
foreach($allowedfiles as $allowedfile) {

if ($done <> "yes") {
if (file_exists($path)) {
echo "A file with this name already exists - please rename the file and reupload.";
exit;
}
}

if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</p>";
echo "<p>Please Note we do not take any responsibility of the images that you upload</p>";
?>
<!-- All the kinds of code you want to be outputed go here -->
<img src="<?php echo "$urltoimages/$name" ?>">
<br>Direct Link: <input name='direct' type='text' align='center' size='70' value='<?php echo "$urltoimages/$name" ?>'>
<br> BB Code:<input name='bbcode1' type='text' align='center' size='70' value=''>
<br> BB Code: <input name='bbcode2' type='text' align='center' size='70' value='[img]<?php echo "$urltoimages/$name" ?>'>
<!-- End of all HTML Code -->
<?php

}
}
if ($done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
}
}
?>

Rockstar
03-10-2007, 08:01 PM
try;

<?
// Script Made By Ashley Cusack
// CONFIG
$siteurl = "http://www.twoupload.com"; //Must Include http:// and www. ending in where the images upload to with NO trailing slash
$serverpath = "images/"; // The End of the part above
$urltoimages = "$siteurl"; // Web address to where the images are accessible from.
$maxsize = "10000"; // Maximum size of the file people can upload
$uniq = uniqid("");
// CONFIG END
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='uploader.php?mode=upload'>\n";
echo "Upload file: <input type='file' name='file'>\n";
echo "<br><input type='submit' name='Submit' value='Upload'>\n";
$bytesize = "1000";
$kb = $maxsize/$bytesize;
echo "<br>Maximum File Size: $kb Kilobytes <em>($maxsize Bytes)</em>";
}
if ($mode == "upload") {
$file = $_FILES['file']['name'];
$name = time() . substr($file, -4);
// If you add your own file types don't forget to add an uppercase version.
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "jfef";
$allowedfiles[] = "jpe";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "JFEF";
$allowedfiles[] = "JPE";
$allowedfiles[] = "PNG";
$allowedfiles[] = "PDF";
$allowedfiles[] = "pdf";
$allowedfiles[] = "PSD";
$allowedfiles[] = "psd";
$allowedfiles[] = "bmp";
$allowedfiles[] = "BMP";
$allowedfiles[] = "tif";
$allowedfiles[] = "tiff";
$allowedfiles[] = "TIF";
$allowedfiles[] = "TIFF";
$allowedfiles[] = "dib";
$allowedfiles[] = "DIB";
$allowedfiles[] = "sql";
if($_FILES['file']['size'] > $maxsize)
{
print "File size is too big - please reduce file size and try again.";
}
else {
$path = "$serverpath/" . $name;
foreach($allowedfiles as $allowedfile) {

if ($done <> "yes") {
if (file_exists($path)) {
echo "A file with this name already exists - please rename the file and reupload.";
exit;
}
}

if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</p>";
echo "<p>Please Note we do not take any responsibility of the images that you upload</p>";
?>
<!-- All the kinds of code you want to be outputed go here -->
<img src="<?php echo "$urltoimages/$name" ?>">
<br>Direct Link: <input name='direct' type='text' align='center' size='70' value='<?php echo "$urltoimages/$name" ?>'>
<br> BB Code:<input name='bbcode1' type='text' align='center' size='70' value=''>
<br> BB Code: <input name='bbcode2' type='text' align='center' size='70' value='[img]<?php echo "$urltoimages/$name" ?>'>
<!-- End of all HTML Code -->
<?php

}
}
if ($done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
}
}
?>

Yey Thanks 1 Problem It dosent take very big files
How Do I make it have more

Assassinator
03-10-2007, 08:01 PM
<?
// Script Made By Ashley Cusack
// CONFIG
$siteurl = "http://www.twoupload.com"; //Must Include http:// and www. ending in where the images upload to with NO trailing slash
$serverpath = "images/"; // The End of the part above
$urltoimages = "$siteurl"; // Web address to where the images are accessible from.
$maxsize = "10000000"; // Maximum size of the file people can upload
$uniq = uniqid("");
// CONFIG END
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='uploader.php?mode=upload'>\n";
echo "Upload file: <input type='file' name='file'>\n";
echo "<br><input type='submit' name='Submit' value='Upload'>\n";
$bytesize = "1000";
$kb = $maxsize/$bytesize;
echo "<br>Maximum File Size: $kb Kilobytes <em>($maxsize Bytes)</em>";
}
if ($mode == "upload") {
$file = $_FILES['file']['name'];
$name = time() . substr($file, -4);
// If you add your own file types don't forget to add an uppercase version.
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "jfef";
$allowedfiles[] = "jpe";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "JFEF";
$allowedfiles[] = "JPE";
$allowedfiles[] = "PNG";
$allowedfiles[] = "PDF";
$allowedfiles[] = "pdf";
$allowedfiles[] = "PSD";
$allowedfiles[] = "psd";
$allowedfiles[] = "bmp";
$allowedfiles[] = "BMP";
$allowedfiles[] = "tif";
$allowedfiles[] = "tiff";
$allowedfiles[] = "TIF";
$allowedfiles[] = "TIFF";
$allowedfiles[] = "dib";
$allowedfiles[] = "DIB";
$allowedfiles[] = "sql";
if($_FILES['file']['size'] > $maxsize)
{
print "File size is too big - please reduce file size and try again.";
}
else {
$path = "$serverpath/" . $name;
foreach($allowedfiles as $allowedfile) {

if ($done <> "yes") {
if (file_exists($path)) {
echo "A file with this name already exists - please rename the file and reupload.";
exit;
}
}

if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</p>";
echo "<p>Please Note we do not take any responsibility of the images that you upload</p>";
?>
<!-- All the kinds of code you want to be outputed go here -->
<img src="<?php echo "$urltoimages/$name" ?>">
<br>Direct Link: <input name='direct' type='text' align='center' size='70' value='<?php echo "$urltoimages/$name" ?>'>
<br> BB Code:<input name='bbcode1' type='text' align='center' size='70' value=''>
<br> BB Code: <input name='bbcode2' type='text' align='center' size='70' value='[img]<?php echo "$urltoimages/$name" ?>'>
<!-- End of all HTML Code -->
<?php

}
}
if ($done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
}
}
?>

Eccentric
03-10-2007, 08:03 PM
<?
// Script Made By Ashley Cusack
// CONFIG
$siteurl = "http://www.twoupload.com"; //Must Include http:// and www. ending in where the images upload to with NO trailing slash
$serverpath = "images/"; // The End of the part above
$urltoimages = "$siteurl"; // Web address to where the images are accessible from.
$maxsize = "10000000"; // Maximum size of the file people can upload
$uniq = uniqid("");
// CONFIG END
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='uploader.php?mode=upload'>\n";
echo "Upload file: <input type='file' name='file'>\n";
echo "<br><input type='submit' name='Submit' value='Upload'>\n";
$bytesize = "1000";
$kb = $maxsize/$bytesize;
echo "<br>Maximum File Size: $kb Kilobytes <em>($maxsize Bytes)</em>";
}
if ($mode == "upload") {
$file = $_FILES['file']['name'];
$name = time() . substr($file, -4);
// If you add your own file types don't forget to add an uppercase version.
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "jfef";
$allowedfiles[] = "jpe";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "JFEF";
$allowedfiles[] = "JPE";
$allowedfiles[] = "PNG";
$allowedfiles[] = "PDF";
$allowedfiles[] = "pdf";
$allowedfiles[] = "PSD";
$allowedfiles[] = "psd";
$allowedfiles[] = "bmp";
$allowedfiles[] = "BMP";
$allowedfiles[] = "tif";
$allowedfiles[] = "tiff";
$allowedfiles[] = "TIF";
$allowedfiles[] = "TIFF";
$allowedfiles[] = "dib";
$allowedfiles[] = "DIB";
$allowedfiles[] = "sql";
if($_FILES['file']['size'] > $maxsize)
{
print "File size is too big - please reduce file size and try again.";
}
else {
$path = "$serverpath/" . $name;
foreach($allowedfiles as $allowedfile) {

if ($done <> "yes") {
if (file_exists($path)) {
echo "A file with this name already exists - please rename the file and reupload.";
exit;
}
}

if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</p>";
echo "<p>Please Note we do not take any responsibility of the images that you upload</p>";
?>
<!-- All the kinds of code you want to be outputed go here -->
<img src="<?php echo "$urltoimages/$name" ?>">
<br>Direct Link: <input name='direct' type='text' align='center' size='70' value='<?php echo "$urltoimages/$name" ?>'>
<br> BB Code:<input name='bbcode1' type='text' align='center' size='70' value=''>
<br> BB Code: <input name='bbcode2' type='text' align='center' size='70' value='[img]<?php echo "$urltoimages/$name" ?>'>
<!-- End of all HTML Code -->
<?php

}
}
if ($done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
}
}
?>
by changing this line;

$maxsize = "10000000"; // Maximum size of the file people can upload

Rockstar
03-10-2007, 08:07 PM
by changing this line;

$maxsize = "10000000"; // Maximum size of the file people can upload
Thanks what do you think best size is

Eccentric
03-10-2007, 08:08 PM
hmmmm too to sure really, 5MB dno what that converts to :P

Want to hide these adverts? Register an account for free!