Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 File Uploading
Index -> Graphics and Design, Web Design -> (X)HTML Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mackie




PostPosted: Tue Feb 19, 2008 12:16 am   Post subject: File Uploading

Hey, just wondering. How I could make a file upload form?
Sponsor
Sponsor
Sponsor
sponsor
uberwalla




PostPosted: Sun Feb 24, 2008 12:09 pm   Post subject: Re: File Uploading

Depending on your servers settings this may work: (just made it quickly)

This file can be named whatever. Index.html, index.php, poo.html (anything basically)
php:

<html>
<head>
</head>
<body>
<form action="upload.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>


This file MUST be named upload.php unless you change the action in the html form.
php:

<?php
$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!";
}
?>


Also i wouldn't recommend having this thing viewable to the public. If you do and it works, you may have a lot of random junk put on your site
Display posts from previous:   
   Index -> Graphics and Design, Web Design -> (X)HTML Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: