The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
Im learning PHP and came up with this script from a tutorial..
Code:
<?php
if(isset($_FILES['file']) == false OR $_FILES['file']['error'] == UPLOAD_ERR_NO_FILE) {
die('Error');
}
if($_FILES['file']['error'] != UPLOAD_ERR_OK) {
die('Error Uploading');
}
$path = '/home/vekaria/public_html/imagehosting/';
$file = $path . $_FILES['file']['name'];
move_uploaded_file($_FILES['file']['name'], $newfile);
die('Done');
?>
How can i make it so when i upload an image it will display the image after it has been uploaded. |
|
#2
|
|||
|
|||
|
PHP Code:
|
|
#3
|
|||
|
|||
|
Im getting this error
Parse error: parse error, unexpected T_STRING in /home/vekaria/public_html/learning.php on line 27 Could you please explain what it means and how to fix it? |
|
#4
|
|||
|
|||
|
Quote:
I updated the tag in my post, it should parse correctly now. By the way, the "unexpected T_STRING" parsing error usually means you didn't close a function correctly. |
|
#5
|
|||
|
|||
|
Thanks, worked perfect
![]() One last thing How can i have it so when an image is uploaded it will also display the link to it aswell.. i tried this ..Code:
<?php
if(isset($_FILES['file']) == false OR $_FILES['file']['error'] == UPLOAD_ERR_NO_FILE)
{
die('Error');
}
if($_FILES['file']['error'] != UPLOAD_ERR_OK)
{
die('Error Uploading');
}
$path = '/home/vekaria/public_html/imagehosting/';
$path2 = 'http://www.lyricalsoundz.com/imagehosting/';
$file = $path . $_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], $file);
// get ext
$ext = substr(strrchr($_FILES['file']['name'], '.'), 1);
// make img array
$imgexts = array('jpg','jpeg','gif','png','jfif','bmp');
if ( in_array($ext, $imgexts) )
{
die('<img src="' . $path2 . $_FILES['file']['name'] . '" />');
}
{
print $path2 . $_FILES['files']['name'];
}
?>
Okay ive managed to get it to display the link but having trouble linking the image to do the url. it just doesnt display when i view the source its there... Code:
<?php
if(isset($_FILES['file']) == false OR $_FILES['file']['error'] == UPLOAD_ERR_NO_FILE)
{
die('Error');
}
if($_FILES['file']['error'] != UPLOAD_ERR_OK)
{
die('Error Uploading');
}
$path = '/home/vekaria/public_html/imagehosting/';
$path2 = 'http://www.lyricalsoundz.com/imagehosting/';
$file = $path . $_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], $file);
// get ext
$ext = substr(strrchr($_FILES['file']['name'], '.'), 1);
// make img array
$imgexts = array('jpg','jpeg','gif','png','jfif','bmp');
if ( in_array($ext, $imgexts) )
{
echo ('<img src="' . $path2 . $_FILES['file']['name'] . '" /> <br />');
}
if ( in_array($ext, $imgexts) )
{
echo ('<a href="' . $path2 . $_FILES['file']['name'] . '" >');
}
?>
wow im getting good at this.here it is.. Code:
<?php
if(isset($_FILES['file']) == false OR $_FILES['file']['error'] == UPLOAD_ERR_NO_FILE)
{
die('Error');
}
if($_FILES['file']['error'] != UPLOAD_ERR_OK)
{
die('Error Uploading');
}
$path = '/home/vekaria/public_html/imagehosting/';
$path2 = 'http://www.lyricalsoundz.com/imagehosting/';
$file = $path . $_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], $file);
// get ext
$ext = substr(strrchr($_FILES['file']['name'], '.'), 1);
// make img array
$imgexts = array('jpg','jpeg','gif','png','jfif','bmp');
if ( in_array($ext, $imgexts) )
{
echo ('<img src="' . $path2 . $_FILES['file']['name'] . '" /> <br />');
}
if ( in_array($ext, $imgexts) )
{
echo ('<a href="' . $path2 . $_FILES['file']['name'] . '" >Image URL</a>');
}
?>
|
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|