Menu
I want an upload form similar to imageshack.us, just where you can upload any file, and it generates a random URL (so more than one name don’t appear several times), and displays the URL when the upload is complete.
and maybe a progress bar.
I am a noob to this, so please elaborate, just so I know what your saying.
I’m not for sure if this should be completely done in php or something else, so sorry if I posted in the wrong section.
Please help!!!
thanks.
<i>
</i>chmod a=rwx /home/stevento/public_html/selfix/
<i>
</i><?
$filename = $_POST['filename']; //this is the filename input of your form
$uploaddir = '/home/stevento/public_html/selfix/uploads/temp/'; //where you want the file to go
$file = basename($_FILES['filename']['name']);
$file = stripslashes($file);
$uploadfile = $uploaddir . $file;
//the move_uploaded_file() function is what moves the temp working file to it's final location.
if (move_uploaded_file($_FILES['filename']['/home/stevento/public_html/selfix/uploads/'], $uploadfile)) {
echo "<pre>";
echo "<span style="color:green;font-weight:bold;">Successfully Uploaded: $file</span>...n";
} else {
echo "<span style="color:#ad0000;font-weight:bold;">upload failed!</span>n";
}
echo 'Here is some more info on your upload:';
print_r($_FILES);
echo "</pre>";
?>
<i>
</i>upload failed! Here is some more info on your upload:Array ( [filename] => Array ( [name] => l_47eee52282beb800613b4bd977e01ba3.jpg [type] => image/jpeg [tmp_name] => /var/tmp/phppty8BE [error] => 0 [size] => 43232 ) )
[code=php]
if (move_uploaded_file($_FILES['filename']['/home/stevento/public_html/selfix/uploads/'], $uploadfile)) {
[/code]
[code=php]
if (move_uploaded_file($_FILES['filename']['tmp_name'], $uploadfile)) {
[/code]
well SSH isn't going to help, if you don't have the right code.
If you fix the code you might get lucky and not have to set permission.[/QUOTE]
[code=php]
error_reporting(E_ALL);
[/code]
<i>
</i>Notice: Undefined index: filename in /home/stevento/public_html/selifx/upload.php on line 3
Warning: move_uploaded_file(/home/stevento/public_html/selfix/uploads/preview.jpg): failed to open stream: No such file or directory in /home/stevento/public_html/selifx/upload.php on line 11
Warning: move_uploaded_file(): Unable to move '/var/tmp/phpUB91dD' to '/home/stevento/public_html/selfix/uploads/preview.jpg' in /home/stevento/public_html/selifx/upload.php on line 11
upload failed! Here is some more info on your upload:Array ( [filename] => Array ( [name] => preview.jpg [type] => image/jpeg [tmp_name] => /var/tmp/phpUB91dD [error] => 0 [size] => 495656 ) )
<i>
</i><?
error_reporting(E_ALL);
$filename = $_POST['filename']; //this is the filename input of your form
$uploaddir = '/home/stevento/public_html/selfix/uploads/'; //where you want the file to go
$file = basename($_FILES['filename']['name']);
$file = stripslashes($file);
$uploadfile = $uploaddir . $file;
//the move_uploaded_file() function is what moves the temp working file to it's final location.
if (move_uploaded_file($_FILES['filename']['tmp_name'], $uploadfile)) {
echo "<pre>";
echo "<span style="color:green;font-weight:bold;">Successfully Uploaded: $file</span>...n";
} else {
echo "<span style="color:#ad0000;font-weight:bold;">upload failed!</span>n";
}
echo 'Here is some more info on your upload:';
print_r($_FILES);
echo "</pre>";
?>
[code=php]
$filename = $_POST['filename']; //this is the filename input of your form
[/code]
<i>
</i>Notice: Undefined index: filename in /home/stevento/public_html/selifx/upload.php on line 3
Warning: move_uploaded_file(/home/stevento/public_html/selfix/uploads/preview.jpg): failed to open stream: No such file or directory in /home/stevento/public_html/selifx/upload.php on line 11
Warning: move_uploaded_file(): Unable to move '/var/tmp/php5JdXsT' to '/home/stevento/public_html/selfix/uploads/preview.jpg' in /home/stevento/public_html/selifx/upload.php on line 11
upload failed! Here is some more info on your upload:Array ( [filename] => Array ( [name] => preview.jpg [type] => image/jpeg [tmp_name] => /var/tmp/php5JdXsT [error] => 0 [size] => 495656 ) )
<i>
</i><?
error_reporting(E_ALL);
$filename = $_POST['filename'];
$uploaddir = '/home/stevento/public_html/selfix/uploads/'; //where you want the file to go
$file = basename($_FILES['filename']['name']);
$file = stripslashes($file);
$uploadfile = $uploaddir . $file;
//the move_uploaded_file() function is what moves the temp working file to it's final location.
if (move_uploaded_file($_FILES['filename']['tmp_name'], $uploadfile)) {
echo "<pre>";
echo "<span style="color:green;font-weight:bold;">Successfully Uploaded: $file</span>...n";
} else {
echo "<span style="color:#ad0000;font-weight:bold;">upload failed!</span>n";
}
echo 'Here is some more info on your upload:';
print_r($_FILES);
echo "</pre>";
?>
<i>
</i>Notice: Undefined index: filename in /home/stevento/public_html/selifx/upload.php on line 3
Warning: move_uploaded_file(): open_basedir restriction in effect. File(/uploads/preview.jpg) is not within the allowed path(s): (/home/stevento/:/usr/lib/php:/usr/local/lib/php:/tmp:/var/tmp:/home/vdeck/tmp/:/usr/local/bin/mogrify:/usr/local/bin/convert:/usr/sbin/sendmail) in /home/stevento/public_html/selifx/upload.php on line 11
upload failed! Here is some more info on your upload:Array ( [filename] => Array ( [name] => preview.jpg [type] => image/jpeg [tmp_name] => /var/tmp/php5JdXsT [error] => 0 [size] => 495656 ) )
<i>
</i>Notice: Undefined index: filename in /home/stevento/public_html/selifx/upload.php on line 3
[code=php]
$filename = $_POST['filename'];
[/code]
[code=php]
...
$file = stripslashes($file);
$file = rand().$file; //this will append a random number to the file name
$uploadfile = $uploaddir . $file;
...
[/code]
[code=php]
echo "post_max_size=" .ini_get('post_max_size') ."<br>"; //returns the integer value
echo ini_get('upload_max_filesize'); //returns full string, not an integer value
[/code]
0.1.9 — BETA 5.12