Uploading w/PHP and i'm a dummy

software development

#1

I’m in a bind here - i need to configure a “Digital Drop Box” to upload files to my website. the problem is that i’m .php impaired.

Does anyone know how i can set this up? - and i’m asking for a lot of help. basically the .php scripts and some nice explicit instructions. I was able to configure phpBB2 on my website, but that had a user-friendly configuration set up - for this drop box assume i’m starting from point B on my trip to point Z.

and a sub question. i also created a directory “cgi-bin” - i didn’t do anything to the folder, just created it, is that enough?

thanks in advance for all the help. i seriously appreciate it.
and UPLOAD SCRIPT would be something great for Dreamhost to provide (in my opinion).

cheers

-j
http://www.uskmaa.com


#2

This has been discussed here before, but for Perl:

Perl Form Upload Source

Here is the final version from that thread:

Upload File Script, Perl Source, final

To use this script, just save into a file with a .pl extension, upload it to a web-accessible directory, and chmod it to 755. Don’t forget to modify the variables first

A cgi-bin directory is not required on DreamHost

:cool: Perl / MySQL / HTML CSS


#3

not to seem ungrateful but … php would be ideal.
what i’m looking for is to be able to upload the files and then have a display of the files uploaded for public viewing.

however, i am trying to configure the .pl and…i’m kind of stuck.

what do enter here
my $upload_success =

and here

$ENV{PATH} = “/bin:/usr/bin”; # set path to known value

i do believe the rest is fine.


#4

Sorry, I can’t help you find something already written to do what you want.

PHP Manual - Chapter 18. Handling file uploads

[quote]what do enter here
my $upload_success =[/quote]
That should be a URL. When the upload is complete, the page has a link that says “Click here to continue.”

Do not change this, it is there for security purposes.

That script is for uploading files to a directory. If you specify a web-accessible directory, then the public will be able to view them, just not with this script. Usually the hurdle is how to upload files and theres no need to re-invent the wheel if you can settle for Perl’s CGI module.

:cool: Perl / MySQL / HTML CSS


#5

Why does it matter if it’s PHP or Perl?

One problem with PHP, by the way, is that you may run into problems if any of the files are larger than the maximum upload file size for PHP (I think the setting is now 40, though I could be wrong).


#6

[quote]One problem with PHP, by the way, is that you may run into
problems if any of the files are larger than the maximum upload
file size for PHP (I think the setting is now 40, though I could be
wrong).

[/quote]

I believe this is currently set to 6-7 MB (at least, it was as of the last time someone asked me about it - a month or two ago, maybe).

  • Jeff @ DreamHost
  • DH Discussion Forum Admin

#7

hey cool! i got this .pl script to work and i can just link to the uploads folder. easy enough. HOWEVER, it won’t upload .txt or .html files. i don’t think this is much of a problem for what i need to doo, but still, just wondering…thanks for the help!!!


#8

What do you mean, it won’t upload? Is the script providing an error message, and if so, which one?

Technically, the browser is doing the uploading - the script just writes it to disk, and that script doesn’t care what type of file it is, so perhaps your browser is using the wrong format for the upload. It works fine using Mozilla, Firefox and Internet Exploiter 6 on WinXP.

:cool: Perl / MySQL / HTML+CSS


#9

yea, i don’t know what is going on. i thought it was a minimum size problem, but that doesn’t seem to be it. the .txt or .html files upload and i get the “thanks for…” etc. and yet when i go to the uploaded files folder, they are at 0K (even if the .html files were 20K uploads). any clues? it’s not that important, like i said, i’m just curious.

though there is one more thing. is there a quick way to add an extra few lines into the code that sends an email when a new file has been added?

that’s my last question…i’ve customized the script the way i like it and it works great!!!

-j


#10

I’m not experiencing the same thing. What I see is a minimum size problem - if the file is less than 4096 bytes, the new file ends up zero-length. This doesn’t occur on my local system which is running WinXP and ActiveState Perl 5.8.0, and I’m apt to blame the File::Copy module in case it’s forgetting to flush the buffer for some reason.

See PerlfectSolutions - Sending email using perl and sendmail. for one way. For the most part, avoid putting data that came from the web in the message headers.

:cool: Perl / MySQL / HTML CSS


#11

The CGI module is using sysopen() for its temporary file, and thus we need to use sysseek() instead of seek() to get the file size and set the file pointer back to the beginning.

Find

seek($filehandle, 0, 2); my $filesize = tell($filehandle);Replace with

sysseek($filehandle, 0, 2); my $filesize = sysseek($filehandle, 0, 1);Find

seek($filehandle, 0, 0);Replace with

sysseek($filehandle, 0, 0);And no more zero-length files for under 4k file sizes

:cool: Perl / MySQL / HTML+CSS


#12

An easy way to find out what the max upload size is is to put ‘phpinfo();’ into a .php file, run it, and look for the line that says ‘upload_max_filesize’

It’s ‘7M’, by the way…

Visit me, please…
www.theraven7.com


#13

Is there a way to change this 7MB limit, or is it fixed by dreamhost?


#14

“File Thingie” is a PHP script that may suit your needs; the script is available from: http://www.solitude.dk/filethingie/

  • marsbar

#15

Compile your own version of php and edit the php ini file and upload this to your site. Instructions should be on the DH wiki.
Silk