I have searched the forums and believe I am in the right section.
I am extremely new to php. I recently acquired a web server that has php6.5 installed and running a port to phpbb. I am aware that phpbb does not allow for uploading files...this was unexpected so I am working another way to do it. I am assuming I need to learn some php to create a form to upload files. Can anyone get me started somewhere? I have Download ed the manual from php.net and will be looking through it, but a more precise location would be appreciated.
Also, I found some programming for uploading a file. I tried using it, but it was like the file wasn't even on the server. I had to do it in a text file, upload it, then change the file extension. I am not sure what opens php files extensions.
Found in another post:
<?php
if($_FILES['file']['temp_name'] != "")
{
copy ($_FILES['file']['temp_name'], "/phpdev/www/".$_FILES['file']['name'])
or die("Could not copy file");
}
else
{ die("No file specified"); }
?>
<html> <head> <title>Upload complete</title> </head>
body <h3>File upload succeeded...</h3>
<ul>
<li>Sent: <?php echo $_FILES['file']['name']; ?>
<li>Size: <?php echo $_FILES['file']['size']; ?> bytes
<li>Type: <?php echo $_FILES['file']['type']; ?>
</ul>
<a href=http://www.htmlforums.com/archive/index.php/"<?php echo $_FILES['file']['name']; ?>">Click here to view file</a>
</body>
</html>
------------------------------------------
I need users to be able to upload files to my web server, specifically pictures. That way when they go to the msg board, they can cross reference the pictures they upload on the msg board using the IMG code. These pictures will not be presented on any webpage that is accessible through a link. I do need the user to be able to know the link to the picture so they can post it: Like a confirmation page that says, "Your picture can be viewed by going to (insert address here)"
Thank you
IH3 Poster.First of all, you don't have a form to upload the file!?
Something like:
<form method="post" enctype="multipart/form-data">
Insert image <input type="file" name="image">
</form>
Then you copy it:
$base_path = "/home/www/mysite/images/".$_FILES['image']['name'];
copy($_FILES['image']['tmp_name'], $base_path);
chmod ($base_path, 0644);
Something of the sort.
HTHOriginally posted by ih3poster
I have searched the forums and believe I am in the right section.
I am extremely new to php. I recently acquired a web server that has php6.5 installed and running a port to phpbb.
uhh no such version in php.
and that code is correct for coping a file to the folder you want. the thing is do you have what Karinne asked? also is the folder you are uploading to chmodded to 0777? you hqave to give permissions to that folder in order to upload.Is the form going to be a different file or does it go into the .php file as well?
Also, what can I use to edit php? I have no way of doing it except through notepad, lol.It's up to you. You can put the form in one file and your script in a different one. I tend to put it all in one file.
There are a few PHP editors out there I'm sure. Personnaly, I've been using Macromedia HomeSite for a few years now rather than notepad - just 'cause the tags are color-coded. I hand code everything. HomeSite also has a nifty little feature which you can do you stuff directly through FTP on HomeSite. That way, you don't have to change a file, upload with FTP then check. I like it. It's color coded for PHP, ASP, HTML, CSS, ColdFusion too I think (I don't use that).
HTH
/ spelling... i suck!
I am extremely new to php. I recently acquired a web server that has php6.5 installed and running a port to phpbb. I am aware that phpbb does not allow for uploading files...this was unexpected so I am working another way to do it. I am assuming I need to learn some php to create a form to upload files. Can anyone get me started somewhere? I have Download ed the manual from php.net and will be looking through it, but a more precise location would be appreciated.
Also, I found some programming for uploading a file. I tried using it, but it was like the file wasn't even on the server. I had to do it in a text file, upload it, then change the file extension. I am not sure what opens php files extensions.
Found in another post:
<?php
if($_FILES['file']['temp_name'] != "")
{
copy ($_FILES['file']['temp_name'], "/phpdev/www/".$_FILES['file']['name'])
or die("Could not copy file");
}
else
{ die("No file specified"); }
?>
<html> <head> <title>Upload complete</title> </head>
body <h3>File upload succeeded...</h3>
<ul>
<li>Sent: <?php echo $_FILES['file']['name']; ?>
<li>Size: <?php echo $_FILES['file']['size']; ?> bytes
<li>Type: <?php echo $_FILES['file']['type']; ?>
</ul>
<a href=http://www.htmlforums.com/archive/index.php/"<?php echo $_FILES['file']['name']; ?>">Click here to view file</a>
</body>
</html>
------------------------------------------
I need users to be able to upload files to my web server, specifically pictures. That way when they go to the msg board, they can cross reference the pictures they upload on the msg board using the IMG code. These pictures will not be presented on any webpage that is accessible through a link. I do need the user to be able to know the link to the picture so they can post it: Like a confirmation page that says, "Your picture can be viewed by going to (insert address here)"
Thank you
IH3 Poster.First of all, you don't have a form to upload the file!?
Something like:
<form method="post" enctype="multipart/form-data">
Insert image <input type="file" name="image">
</form>
Then you copy it:
$base_path = "/home/www/mysite/images/".$_FILES['image']['name'];
copy($_FILES['image']['tmp_name'], $base_path);
chmod ($base_path, 0644);
Something of the sort.
HTHOriginally posted by ih3poster
I have searched the forums and believe I am in the right section.
I am extremely new to php. I recently acquired a web server that has php6.5 installed and running a port to phpbb.
uhh no such version in php.
and that code is correct for coping a file to the folder you want. the thing is do you have what Karinne asked? also is the folder you are uploading to chmodded to 0777? you hqave to give permissions to that folder in order to upload.Is the form going to be a different file or does it go into the .php file as well?
Also, what can I use to edit php? I have no way of doing it except through notepad, lol.It's up to you. You can put the form in one file and your script in a different one. I tend to put it all in one file.
There are a few PHP editors out there I'm sure. Personnaly, I've been using Macromedia HomeSite for a few years now rather than notepad - just 'cause the tags are color-coded. I hand code everything. HomeSite also has a nifty little feature which you can do you stuff directly through FTP on HomeSite. That way, you don't have to change a file, upload with FTP then check. I like it. It's color coded for PHP, ASP, HTML, CSS, ColdFusion too I think (I don't use that).
HTH
/ spelling... i suck!