Jump to content
Sign in to follow this  
MothaCuss

Webpage Uploads Through Html Post Method?

Recommended Posts

Ok...so i'm trying to create a little webpage that allows you to upload pictures. I've gotten some code from a friend and it looks as follows:

 

><%
 Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
 If Form.State = 0 Then
   Form.Files.Save "C:\Uploads"
 Else 
   'Handle other form states.
 End If
%>
<body bgcolor="#FFFFFF">
<form method=post ENCTYPE="multipart/form-data">

<input type="submit" value="Upload the files >>"><br>
<Div ID=files>
File 1 : <input type="file" name="File1"><br>
File 2 : <input type="file" name="File2">
</Div>
<Input Type=Button Value="+Add a file" OnClick=Expand()>
<script>
 var nfiles = 2;
 Function Expand(){
   nfiles++;
   files.insertAdjacentHTML('BeforeEnd','<BR> File '+nfiles+' : <input type="file" name="File'+nfiles+'">');
 }
</Script>
</Body>

 

It's telling me this:

 

Method Not Allowed

The requested method POST is not allowed for the URL /kiwwa/test.html.

 

I set all the permissions to allow anything and everything to be done to the website. How do i fix this or is there a better way of doing this or something? I've heard of using .asp's etc...anyone know anything bout that?

Share this post


Link to post
Share on other sites

Moving to scripting forum for organization.

 

This looks like an ASP code. I don't think ASP runs on the servers at TCH.

Edited by TCH-Bruce

Share this post


Link to post
Share on other sites

Yeah, I see that too. Some VB Script running via ASP. Sorry my friend, that will be your first battle!

 

You can to #includes and they do the same thing really in PHP and Perl.

Share this post


Link to post
Share on other sites

Do you think that i could post from a flash file? Would that possibly work? Like...i don't understand what my overall problem is...is it the asp file type or is it my permissions in my .htaccess thats not allowing me my post method? I havent set up any post method things on my site yet so it could be permissions...though i set the folder called kiwwa to be 777.

Share this post


Link to post
Share on other sites

The problem is ASP does not run on these servers. If you created something in PHP or Perl they woudl run.

Share this post


Link to post
Share on other sites

Ok...now i'm getting a 500 internal server error when i try to run the script you suggested. I have my cgi-bin and upload.cgi file set to 755 so i don't know what the problem is. I set everything up correctly as far as i know...is it something you guys have to enable.

Share this post


Link to post
Share on other sites

Ok, I've just uploaded and tested it and it works great.

 

Modify the upload.cgi file for the following fields.

 

$dir = "/home/(cpanel login)/{path-to-upload-folder}";

where you replace (cpanel login) with your login and

replace {path-to-upload-folder} with where you intend the uploads to go like "public_html/uploads"

 

$folder = "http://www.******/{upload folder}/";

Where you replace YOURDOMAIN with your domain name and {upload folder} with the folder you create to upload into

 

$max = 200;

With how big a file in kilobytes you will allow

 

$domain = "YOURDOMAIN";

Enter your domain for YOURDOMAIN

 

$notify = 'YOUR EMAIL ADDRESS';

Enter your email address

 

That's all that needs modified in the upload.cgi script. Save it and upload it to your cgi-bin folder and change file permissions to 755

 

Now modify the demo.html file and modify the path to the upload.cgi file

 

form action="http://www.******/cgi-bin/upload.cgi"

 

Now save and upload that file to your webspace.

 

Now create the folder you told the script to use in the proper path on the server. I created an uploads folder in my public_html folder and changed the permissions of the folder to 777.

 

Test the script it should work.

 

If you did all that, did you upload the upload.cgi file in ASCII mode or Binary? It must be uploaded in ASCII mode for it to work.

Edited by TCH-Bruce

Share this post


Link to post
Share on other sites

Well i did all you said and it still doesn't work. I uploaded it through the cpanel file control thing...would that effect it? It still gives me the 500 internal server error but i have everything set right. Maybe i'm not doing the form part right? You just put what file you want to upload right?

 

Edit: I'm not retarded either haha. I know a bit about php and scripting so i didn't make any overt errors as far as i know.

Share this post


Link to post
Share on other sites

I would use FTP (not cpanel) and upload in ascii.

 

Also - don't edit it in cpanel either.

Share this post


Link to post
Share on other sites

I'm not sure the cpanel upload will upload the file in ASCII or not. Like Ty says, use an FTP client and force it to upload in ASCII.

 

I also failed to mention the last config section where you edit in the extensions of the files you will allow to be uploaded. Make sure the file's extension you are uploading is included in the upload.cgi on a separate line.

Edited by TCH-Bruce

Share this post


Link to post
Share on other sites

Yeah, there ya go. Mike's got it for you.

 

Actually, if I was to give you an example of uploading in PHP, I'd have to give you my own code.. I ended up researching it myself for a couple of uses I needed uploading for on my website.

Share this post


Link to post
Share on other sites

I am just trying to set up a page where members could upload pictures as well. I have tried several different scripts, but they all fail. I do not get any real error messages, they just will not upload the pictures.

 

Could this be because I have modified the .htaccess for aMember?

 

If not, is there something I need to change? I have the permissions of the folder to post to set at 777.

 

Here is the information from the .cgi file.

 

$dir = "/home/ndycnua/public_html/photos/pictures";

$folder = "http://www.bsatroop98.org/photos/pictures";

$max = 500;

$domain = "www.bsatroop98.org";

$redirect = "/localhost/photos/index.html";

$notify = 'kajoiner@bsatroop98.org';

$send_mail_path = "/ndycnua/sbin/sendmail";

$smtp_path = "mail.bsatroop98.org";

Share this post


Link to post
Share on other sites
$folder = "http://www.bsatroop98.org/photos/pictures";

Try adding a trailing slash to this line:

 

$folder = "http://www.bsatroop98.org/photos/pictures/";

 

$send_mail_path = "/ndycnua/sbin/sendmail";

 

Shouldn't the path be /usr/sbin/sendmail

Edited by TCH-Bruce

Share this post


Link to post
Share on other sites

I made those changes and this is the result.

 

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@bsatroop98.org and inform them of the time the error occurred, and anything you might have done that may have caused the error.

 

More information about this error may be available in the server error log.

 

 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

 

--------------------------------------------------------------------------------

 

Apache/1.3.29 Server at www.bsatroop98.org Port 80

Share this post


Link to post
Share on other sites

I looked in the error log and this entry was there.

 

error: file is writable by others: (/home/ndycnua/public_html/photos/cgi-bin/upload.cgi)

 

Mean something to you?

Share this post


Link to post
Share on other sites

I changed the permission on the .cgi file and retried. I received this error.

 

Invalid referrer.

Share this post


Link to post
Share on other sites

I found the mistake. I had

$domain = "www.bsatroop98.org";

 

when it should have been

$domain = "bsatroop98.org";

 

The script works great. I had to modify it to do more than 2 files at a time, but that was easy. Thanks for the help. Rock Sign

Share this post


Link to post
Share on other sites

Glad you got it working. :lol:

 

The above mentioned script will also upload a file with the same filename and rename it with a number appended. Something to think about if the script you are using doesn't check for this and just overwrites a file already uploaded.

Share this post


Link to post
Share on other sites

This script seems to be working fine for the most part, but I did find one problem that I don't know how to fix. I made a small change to the script to change the number that could be uploaded at one time from 2 files to 10 files. That change works fine, but if there is an error in any of the 10 files (ie, one of the files is too large), it returns an error for the one file but does not upload the other 9 files.

 

Is there someway to correct this?

 

The user that recieved the error thought that the other 9 files were uploaded because he did not recieve and error on them.

Share this post


Link to post
Share on other sites

Ok...this is getting extremely annoying. It still doesn't work. Here is my code:

 

$dir = ""/home/freecit/kiwwa";";

$folder = "http://www.freecityskates.com/kiwwa/";

$max = 2000;

$domain = "freecityskates.com";

$redirect = "http://www.freecityskates.com/index.html";

$notify = 'brett@freecityskates';

$send_mail_path = "/usr/sbin/sendmail";

$smtp_path = "mail.freecityskates.com";

 

The permissions of the cgi-bin, the upload.cgi, and the "kiwwa" folder are all set to being 755. I can see nothing wrong with my code and i am only trying to upload files that are with the right extension. I keep getting 500 Internal Server errors....WHY!?!? This makes no sense!!! Is there something else that could be interfering? Some other permissions or files that don't allow this script to worK??

 

These are all the errors in my error log from my attempts at uploading...

 

[2004-03-24 12:32:08]: error: file has no execute permission: (/home/freecit/public_html/cgi-bin/upload.cgi)

[Wed Mar 24 12:46:12 2004] [error] [client 128.233.107.55] Premature end of script headers: /home/freecit/public_html/cgi-bin/upload.cgi

[Wed Mar 24 12:36:40 2004] [error] [client 128.233.107.55] Premature end of script headers: /home/freecit/public_html/cgi-bin/upload.cgi

[Wed Mar 24 12:36:30 2004] [error] [client 128.233.107.55] Premature end of script headers: /home/freecit/public_html/cgi-bin/upload.cgi

[Wed Mar 24 12:34:39 2004] [error] [client 128.233.107.55] Premature end of script headers: /home/freecit/public_html/cgi-bin/upload.cgi

[Wed Mar 24 12:34:09 2004] [error] [client 128.233.107.55] Premature end of script headers: /home/freecit/public_html/cgi-bin/upload.cgi

[Wed Mar 24 12:32:08 2004] [error] [client 128.233.107.55] Premature end of script headers: /home/freecit/public_html/cgi-bin/upload.cgi

 

Anyone know what this means?

Share this post


Link to post
Share on other sites
$dir = ""/home/freecit/kiwwa";";

$folder = "http://www.freecityskates.com/kiwwa/";

$max = 2000;

$domain = "freecityskates.com";

$redirect = "http://www.freecityskates.com/index.html";

$notify = 'brett@freecityskates';

$send_mail_path = "/usr/sbin/sendmail";

$smtp_path = "mail.freecityskates.com";

 

I had some problems with this as well, so I am no expert, but I think you need to change the following.

 

$dir = "/home/cpanel login name/public_html/kiwwa/"; - I think you have too many "s

 

Take out the redirect for now. I had several problems with that and found it easier to leave that out until I worked out the other problems.

 

Try that and see what it does.

Share this post


Link to post
Share on other sites

...it works. It was either the stupid domain not liking me or the fact that i didn't put in public_html. This lack of sleep is really killing me. Thx so much to everyone who helped out, i appreciate it tons. Rock Sign

Share this post


Link to post
Share on other sites
This script seems to be working fine for the most part, but I did find one problem that I don't know how to fix.  I made a small change to the script to change the number that could be uploaded at one time from 2 files to 10 files.  That change works fine, but if there is an error in any of the 10 files (ie, one of the files is too large), it returns an error for the one file but does not upload the other 9 files.

 

Is there someway to correct this?

 

 

The user that recieved the error thought that the other 9 files were uploaded because he did not recieve and error on them.

 

Any help?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...