*RESOLVED* Upload file to host.
Posted: Sat Sep 20, 2003 6:08 pm
Hello, I have already searched this forum and looked through many topics on the php.net website, consulted a php friend (but he had to leave early) AND googled my topic and I am still very frustrated. My host is running Red Hat Linux (I don't know if that matters).
I want to be able to upload my php files to the server. That's pretty basic, but I can't get it to work. Here is my html script:
=> You can see an example of this page at: http://www.paredes.cc/brandon/form.html
and here is my php code:
I am thining that it is a problem with the path, but I have tried many different variants including simply: /uploads/$user_file.
In the SAME directory as these files is a folder called "uploads" as my code shows. So, in conclusion, I do not know why this code is not working. I have beed fiddling with it all day and still, I get nothing. Any help would be greatly appreciated.
Also, i was wondering if it was possible to substitute:
with
Thank you,
Brandon Paredes
I want to be able to upload my php files to the server. That's pretty basic, but I can't get it to work. Here is my html script:
Code: Select all
form.html
<html>
<head><title></title></head>
<body>
<form method="post" action="upload.php" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<B>Select a File to Upload<br></B>
<input type="file" name="$user_file" size="50"><br><br>
<b>Personal Information (NOT OPTIONAL)</b>
<table>
<tr>
<td>
Your full name:
</td>
<td>
<input type="text" name="user_fname" length="20"> &nbsp <input type="text" name="user_lname">
</td>
</tr>
<tr>
<td>
Your email address:
</td>
<td>
<input type="text" name="email_address" size="15"> @ <input type="text" name="username" size="15"> . <input type="text" name="username" size="3">
</td>
</tr>
<tr>
<td valign="top">
Description of the file: &nbsp &nbsp
</td>
<td>
<textarea name="file_description" cols="34" rows="5" wrap="virtual"></textarea>
</td>
</tr>
</table>
<br><input type="submit" value="Upload my file">
</form>
</body>
</html>and here is my php code:
Code: Select all
upload.php
<?php
/* Copyright © 2003 Brandon Paredes. All rights reserved.
brandon@paredes.cc */
if ($user_file == "none"){
echo "No file specified";
exit;
}
if (copy($userfile, "/public_html/brandon/uploads/$user_file")) {
echo "Your file has been sucessfully uploaded.";
} else {
echo "Your file was not uploaded.";
}
?>In the SAME directory as these files is a folder called "uploads" as my code shows. So, in conclusion, I do not know why this code is not working. I have beed fiddling with it all day and still, I get nothing. Any help would be greatly appreciated.
Also, i was wondering if it was possible to substitute:
Code: Select all
if ($user_file == "none"){Code: Select all
if (!($user_file)) {Brandon Paredes