PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 9th, 2004, 11:31 AM
b0881 b0881 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 b0881 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
File Upload

Well.. I am in desperate need of a php script.

All I want is a simple form on a webpage where you can browse for a file, e.g an Image file then upload to a directory on my server.

I've visited countless websites with countless scripts but I only managed to ever get one to work and when it did the max filesize was something like 15kb which was far too small.

Any help would be GREATLY appreciated as Im useless with PHP.

Cheers

~~

Reply With Quote
  #2  
Old July 9th, 2004, 12:33 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
There are several tutorials and many threads on this topic here. Take a look around and see how far you can get. Then come back with any specific questions.
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #3  
Old July 13th, 2004, 03:57 AM
anuradhaj anuradhaj is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 anuradhaj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
File Upload sample..

File Upload sample.
note : there's a restriction for file size
think you can easily edit and change the size here
PHP Code:
<?php
  $user_name 
"anuradha";
 
$user_id 1;
 
/*rename files user id vise*/
 
 
if ($HTTP_POST_VARS['submit']) {
     
/*print uploaded file description*/
   
print_r($HTTP_POST_FILES);
   
   if (!
is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) {
     
$error "You did not upload a file!";
     
unlink($HTTP_POST_FILES['file']['tmp_name']);
     
/* assign error message, remove uploaded file, redisplay form.*/
   
} else {
     
/*a file was uploaded*/
     
$maxfilesize=1024000000;
     
     if (
$HTTP_POST_FILES['file']['size'] > $maxfilesize) {
       
$error "file is too large";
       
unlink($HTTP_POST_FILES['file']['tmp_name']);
       
/* assign error message, remove uploaded file, redisplay form.*/
     
} else {
         if (
$HTTP_POST_FILES['file']['type'] == "" AND $HTTP_POST_FILES['file']['type'] == " ") { 
       
//if ($HTTP_POST_FILES['file']['type'] != "image/gif" AND $HTTP_POST_FILES['file']['type'] != "image/pjpeg") { 
         
$error "This file type is not allowed";
         
unlink($HTTP_POST_FILES['file']['tmp_name']);
         
/* assign error message, remove uploaded file, redisplay form.*/
       
} else {
        
//File has passed all validation, copy it to the final destination and remove the temporary file:
        
copy($HTTP_POST_FILES['file']['tmp_name'],"{$user_id}~".$HTTP_POST_FILES['file']['name']);
        
unlink($HTTP_POST_FILES['file']['tmp_name']);
        print 
"<br>File has been successfully uploaded!";
        exit;
      }
     } 
   }
 }
 
?>
 
 <html>
 <head></head>
 <body>
 <form action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data">
 <?php
 
if(isset($error))
 {
     echo 
$error;
 }
 
 
?>
 <br><br>
 FILE TO UPLOAD : : <br>
 <input type="file" name="file"><br>
 <input type="submit" name="submit" value="submit">
 </form>
 </body>
 </html>

Last edited by stumpy : July 13th, 2004 at 08:42 AM. Reason: Please place CODE IN [CODE] OR [PHP] TAGS!

Reply With Quote
  #4  
Old July 19th, 2004, 10:00 AM
dtalukdar dtalukdar is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Location: KS, USA
Posts: 3 dtalukdar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to dtalukdar
OK - it appears that you have an issue with the file size from what you are saying... I have to warn you ahead of time that PHP by default has a value in the PHP.INI file that governs the file size. The parameter is called "upload_max_filesize" and by default is set to 2MB. You shouldn't have any trouble uploading anything upto 2MB, but beyond that, to the best of my knowledge, you will need to have access to your PHP.INI file to be able to change that value. You should see something to the effect of the following in there....

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

Its this value that you will have to change

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > File Upload


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway