|
|
Can somebody help make me a PHP uploader?
|
|
|
|
Grizzled Veteran
Join Date: Jan 2001
Location: Iowa State Univesity
Status:
Offline
|
|
I've looked at a ton of tutorial and stuff but I can't seem to get it to work. All I want to do is have a web page where I can browse, choose a file, then upload it to my server. It's running OS 10.4.5 with Apache 1.3 and PHP 5.1.2. The server's address is http://gossamerthree.student.iastate.edu, and the file path for uploads would be /Library/WebServer/Documents/Uploads. This is just a little server of my own to put pictures and stuff on, security is not important, but for what I'm doing with it it would be nice to have a little password or something. Can any of you gurus help me?
|
iBook G4-1.33/768 || B&W G3-450/640 || Beige G3-G4 450/352 || Beige G3-400/256 in Classic case || Beige G3-300/256 || PB 5300cs Pictureframe 100/24
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Aug 2000
Location: Minneapolis, MN
Status:
Offline
|
|
Why does it have to be a web upload? For what you want, just enable Ftp? I can't imagine a scenario where you have a web access but not FTP unless the ftp traffic is blocked.
FTP would be dead simple, gives you basic authentication and just works.
For PHP there are some scripts around. I'll look at the code I have for uploads. Its not like you want the uploaded file to then be available for viewing on your web browser, right?
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Jan 2001
Location: Iowa State Univesity
Status:
Offline
|
|
I had considered FTP, but discarded it initially because I'd like for totally non-computer literate people to use this, but really it's not hard to figure out, so I might go with that anyway. What's the best FTP server software for OS 9?
The main point of this project is to allow people to remotely change the desktop picture, so if I use an app that automatically changes the picture at a set interval and set pictures to go into a specific folder that the program reads out of, it should work fine.
|
iBook G4-1.33/768 || B&W G3-450/640 || Beige G3-G4 450/352 || Beige G3-400/256 in Classic case || Beige G3-300/256 || PB 5300cs Pictureframe 100/24
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status:
Offline
|
|
What code have you tried to get to function? And what errors are you receiving when you're working on it?
|
2008 iMac 3.06 Ghz, 2GB Memory, GeForce 8800, 500GB HD, SuperDrive
8gb iPhone on Tmobile
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Jan 2001
Location: Iowa State Univesity
Status:
Offline
|
|
I can't find the tutorials I was using earlier. None of them really had the code written out though, just randoms bits through, which made it hard to copy and paste well.
|
iBook G4-1.33/768 || B&W G3-450/640 || Beige G3-G4 450/352 || Beige G3-400/256 in Classic case || Beige G3-300/256 || PB 5300cs Pictureframe 100/24
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status:
Offline
|
|
|
2008 iMac 3.06 Ghz, 2GB Memory, GeForce 8800, 500GB HD, SuperDrive
8gb iPhone on Tmobile
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Jan 2001
Location: Iowa State Univesity
Status:
Offline
|
|
Originally Posted by SirCastor
Okay, here is my severly flawed code:
uploader.html:
Code:
<HTML>
<HEAD>
<TITLE>uploader.html</TITLE>
</HEAD>
<BODY>
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</BODY>
</HTML>
and uploader.php
Code:
<HTML>
<HEAD>
<TITLE>uploader.php</TITLE>
</HEAD>
<BODY>
<?php
// Where the file is going to be placed
$target_path = "uploads/";
/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
// This is how we will get the temporary file...
$_FILES['uploadedfile']['tmp_name'];
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
</BODY>
</HTML>
when i choose a picture and hit upload, safari takes me to a blank page called uploader.php and nothing else happens. I know there are horrid errors there, let me know what they are!
|
iBook G4-1.33/768 || B&W G3-450/640 || Beige G3-G4 450/352 || Beige G3-400/256 in Classic case || Beige G3-300/256 || PB 5300cs Pictureframe 100/24
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status:
Offline
|
|
Your code worked flawlessly for me. Here's two things:
1) Make sure that the uploads directory exists, and that it has permissions set properly to be written to by the web server (in the case of OS X, it's user 'www')
2) If you're still running into difficulties, turn on error displaying in PHP on the server. It's immensly useful when you're trying to figure out what's going on.
I'd be willing to bet it's a permissions issue over anything else.
If you have more questions, ask away.
|
2008 iMac 3.06 Ghz, 2GB Memory, GeForce 8800, 500GB HD, SuperDrive
8gb iPhone on Tmobile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|