Click to See Complete Forum and Search --> : getting jpg from customer


Marlbil
01-17-2003, 02:40 PM
I have <input name="picture" type="file" size="30"> on a web page. When customer clicks "submit" how do I get that picture. I'm using form mail which gets me everything except the actual jpg.

Thanx

khalidali63
01-17-2003, 07:46 PM
It will be interesting if some can come up with a JavaScript soultion for you.

Khalid

AdamGundry
01-18-2003, 05:45 AM
You generally can't use client-side Javascript to do anything server-side. You'd probably need a Perl or PHP script (or similar server-side script) to save the uploaded file on the server, or see if there is a form-to-mail script which handles images as well.

Adam

Marlbil
01-18-2003, 08:53 AM
I have a tech support request asking if I can use php code and if so if I need to do anything to activate the code. I know nothing of php so I got some help on the web. That resulted in this coding attempt:

<?
<FORM NAME='upload' ACTION='processing.php' METHOD='post' ENCTYPE='multipart/form-data'>
?>

<input name="picture" type="file" size="30">

<input type="submit" value ="Send your ad">

I get the other data but not the jpg.

pyro
01-18-2003, 10:17 AM
Originally posted by Marlbil
<?
<FORM NAME='upload' ACTION='processing.php' METHOD='post' ENCTYPE='multipart/form-data'>
?>That is incorrect. You don't need the PHP <? ?> there at all, since you would just be calling the PHP when you submit the form. But if you want them, this is how you'd write it...

<?PHP
echo ("<FORM NAME='upload' ACTION='processing.php' METHOD='post' ENCTYPE='multipart/form-data'>");
?>And rename you pages to .php if you use the latter method. But, use the former (no PHP in your form), as there is no need to use PHP for this part...

Marlbil
01-18-2003, 11:13 AM
Thanx Pyro, I'll try it.

I'm Back.

When I tried it there was some processing but finally got a http 404 file not found.

"http://stuffused.com/processing-php

The code can be found at stuffused.com/SubmitAdPHP.html

pyro
01-18-2003, 12:45 PM
Are you sure you have processing.php uploaded to the same directory as the html page with the form is? If not, that is why it won't work.

Marlbil
01-18-2003, 07:36 PM
Thanx Pyro, a sincere thank you for your help. I did get a response from my hosts tech support. They said to:

Add a .htaccess file to the directory with the following line:


AddType application/x-httpd-php .html
AddType application/x-httpd-php .htm

I'm confused .htaccess is the whole name of the file? I don't put anything in front of the .

Stefan
01-18-2003, 08:05 PM
Originally posted by Marlbil
I'm confused .htaccess is the whole name of the file? I don't put anything in front of the . [/B]

No, just .htaccess

jeffmott
01-18-2003, 09:06 PM
Dave Clark
http://soupermail.sourceforge.net/index.html
I was curious if this script did anything amazingly special? I just took a look at it and it's roughly 3,000 lines of code! That's an awful lot for a simple form mailer.

Marlbil
01-19-2003, 09:41 AM
My form still isn't working. I know I'm doing something wrong. Here is what I did:

In note pad I created .htaccess with the 2 lines from a previous post. the result was .htaccess.txt

In my FTP I renamed it to get rid of the .txt.

I copied it to the public directory, it finished although it never appears in the listing of files.

pyro
01-19-2003, 09:52 AM
When you create your file in Notepad, choose file save as. In the save as type, choose all files. Now save as .htaccess

Stefan
01-19-2003, 09:58 AM
Originally posted by pyro
When you create your file in Notepad, choose file save as. In the save as type, choose all files. Now save as .htaccess

Isn't the problem that Notepad is saving the file in Windows format while the server needs it in *nix format?

I would visit my prefered free software site (in my case it's www.nonags.com ) and download a replacement for Notepad that enables you to save in linux linebreak format.

pyro
01-19-2003, 10:05 AM
In notepad, you can choose to save in unicode format...

Stefan
01-19-2003, 11:20 AM
Originally posted by pyro
In notepad, you can choose to save in unicode format...

Hmm, I guess that is dependent on which notepad you have.
At least on Win98SE I don't see that option in notepad.

Marlbil
01-19-2003, 12:00 PM
Well Guys when I do that it appears nowhere. I guess I'm just not up to speed on this technical stuff. I get lost when something out of the usuall occurs.

pyro
01-19-2003, 12:24 PM
Originally posted by Stefan
Hmm, I guess that is dependent on which notepad you have.
At least on Win98SE I don't see that option in notepad. Interesting...I'd have thought notepad was notepad. :D I'm running XP, so they must have updated it a bit...

Marlbil
01-20-2003, 09:03 AM
Well atleast there is a solution by upgrading from Windows 98 to XP. However, does anyone know of a Notepad type program that will "save as" in a unicode extension. By the way, what is that extension?

Daria
01-20-2003, 09:16 AM
You can also save it in a WordPad
[start/programs/accessories/WordPad] - it will give you an option of a Unicode, .

You can do it basically in any WP - even Microsoft Word has a text only (*.txt) option. In other processors make sure that you choose All Files *.* in Save As Type option and enter filename as yourfile.txt

It should always get you to plain text only, and go from there.

Marlbil
01-20-2003, 05:25 PM
Using wordpad I created a .htaccess saved as unicode that looks like this:

’žA d d T y p e a p p l i c a t i o n / x - h t t p d - p h p . h t m l

A d d T y p e a p p l i c a t i o n / x - h t t p d - p h p . h t m

Using wsftp I copied into the public directory. I note that it never appears in my directory listing of public.

I ran my upload with this coding:

<FORM NAME='upload' ACTION='processing.php' METHOD='post' ENCTYPE='multipart/form-data'>

<input type="submit" value ="Send your ad">

I get a file not found and tech support tells me it's there. They refuse to debug my html code.

I need help.

King Pellinore
01-20-2003, 08:38 PM
What is in your processing.php?

A file wont magically jump to the directory you want, you will need to put it there.

Check out
http://www.php.net/manual/en/function.is-uploaded-file.php

but most importantly
http://www.php.net/manual/en/function.move-uploaded-file.php

That takes the file out of php and stuffs it into the correct destination.

Daria
01-21-2003, 08:29 AM
When saving in Notepad, save using quotation marks, such as

".htaccess"

It will prompt you about saving it as a text file and overwriting formatting - ignore it. As long as you have quotation marks around the full name, it should be fine.
Same goes for perl and such.

Marlbil
01-23-2003, 09:43 AM
i'M READY TO GIVE UP AND OFFER TO PAY SOMEONE TO HELP ME.

On my computer my .htaccess file appears with no name

My ftp'd copy on my server never shows at all

My html looks like this:
<FORM NAME="newad" ACTION="processing.php" METHOD="post" ENCTYPE="multipart/form-data">

Whrn I click submit it does some processing before I get

http 404 FILE NOT FOUND

hELP

King Pellinore
01-27-2003, 07:24 PM
Ok, if you are still listening to this thread, I'll try to help you. I see that you said that you are not experienced with php, so I'll try to take it step by step.

This thread is going off different tangents, which don't even relate to your problem.

Ok. You are using php now. No more mail form uploads, right? Right.

Put this in a normal html file:<from name="upload" action="processing.php" method="post" enctype="multipart/form-data">
<input name="picture" type="file" size="30" />
<input type="submit" value="Send your ad" />
</form>Nearly what you did before.
Ok, note that I've highlighted action="processing.php". This is a very important line. This means that when a user hits that Submit button (which says "Send your ad" in your form), their web browser is going to go to the page in the "action" attribute. Just as if you typed it in the Address bar (or equivalent) and pressed enter. So, in this case, for example, if the html file with the code above is at
http://www.domain.com/send_ad.html
, when the user clicks the Submit button, their browser will try to access
http://www.domain.com/processing.php
PLUS it will send a file to the server.

We are on processing.php now, we left the html file with the form above.

When the browser sends the file to the server, the server gives it to the program PHP and this program puts the file into a special directory, but this doesn't matter. What matters is that you need to have the following code in that processing.php:<?php
if (is_uploaded_file($_FILES['picture']['tmp_name']) {

move_uploaded_file($_FILES['picture']['tmp_name'],"$WebRoot/images/$ItemID.jpg");
}
else {
// Error handling
}
?>There are a few things to note here:

You may have a different version of php. In that case, the code might be different. Check the code for your version by searching at http://www.php.net/
This function first checks if the file upload was successful. If it was, then we tell php to move the file from wherever it put it to the directory you want it to be in. (Note, if you don't do this, then php will delete the file from wherever it put it, once you leave processing.php)
The array $_FILES stores the filenames (correct me here ye php experts, if I'm wrong) of the uploaded files.
I've highlighted picture. This is the same name, that the <input type="file" name="picture" ...> tag has.
The following is the path of where you want the file to be: "$WebRoot/images/$ItemID.jpg". Note that this may be very different on your system. You might want to use a different filename, but these are just details, which will be easy to figure out.


That's it. Tell me if I didn't understand what you wanted correctly and you already knew all this. Also, ask your admin to check the code for the processing.php file.

Finally, if you find a solution, whether it is this or another, please post a follow up, so people in the future with a similar problem can see what worked in the end.

Alright?

Marlbil
01-28-2003, 09:57 AM
King, I thank you for your efforts. Part of my difficulty is no tech support from my web host. This is turning out to be more problems than it's worth. It seems, at this point, much easier to to have folks email the jpg so I can set up the classified ad for them.

It appears that I need to load php on my web site, learn to write code etc. I did this stuff for 40 years. It's why I retired!