Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-23-2004, 12:31 PM   #1 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 209
falsepride is on a distinguished road
uploading images

okay i really don't have time to look up how to upload an image. all i need is an extremely basic script that uploads a image into a designated folder of my chioce. can anyone do me this favor? please help me out soon as possible
falsepride is offline   Reply With Quote
Old 11-23-2004, 01:01 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
even though i hesitate to help someone who's excuse is meerely that they don't have time, i'll point you in the right direction. my time must not be as valuable as yours.

in short, there are 4 steps to this process.

1. add enctype="multipart/form-data" to your form tag.
2. add a file field <input type=file name=file>
3. after the form is submitted, use the $_FILES[] array to get your data. The temporary file for this example would be $_FILES['file']['tmp_name']
4. copy the temporary file to a directory which allows the web user to write to.

All the elements are here, .. now you just need to put them together.

Good Luck!
__________________
Mike
sde is offline   Reply With Quote
Old 11-23-2004, 01:07 PM   #3 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 209
falsepride is on a distinguished road
well im running dial up, with only one phone line in my house, testing php scripts can be a tedious task, and i have a lot of coding ahead me of for what im working on, and i mean a lot
falsepride is offline   Reply With Quote
Old 11-23-2004, 06:17 PM   #4 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
Quote:
Originally Posted by falsepride
well im running dial up, with only one phone line in my house, testing php scripts can be a tedious task, and i have a lot of coding ahead me of for what im working on, and i mean a lot
If you haven't already setup a local installation of apache/php/mysql/etc then I'd highly recommend it. Check out the Apache2Triad project for a bundle of everything already configured for windows use. There are also several other similar projects, but I can't remember them right now.

With something like that installed, you can do some local dev without dialing up. It might also be helpful to download the php docs to view offline.

-r
idx is offline   Reply With Quote
Old 11-23-2004, 06:30 PM   #5 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 209
falsepride is on a distinguished road
i once had something set up where i could test php files without uploading. i found the instructions at http://poff.sixbit.org/article.php?apache. but i think it wouldn't recognize variables passed through the url and it was pissing me off because parts of my site weren't display properly.
falsepride is offline   Reply With Quote
Old 11-23-2004, 07:37 PM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
you need to set register_globals to on in the php.ini file. otherwise, you need to use $_GET[] to retreive url variables and $_POST[] for post variables.

i ALWAYS use $_GET[] and $_POST[] anyway so my applications are more portable and I don't fear that if this setting on a server was changed, that my scripts would fail.
__________________
Mike
sde is offline   Reply With Quote
Old 11-23-2004, 07:42 PM   #7 (permalink)
Kernel_Killer
Regular Contributor
 
Kernel_Killer's Avatar
 
Join Date: Feb 2003
Location: indisclosed
Posts: 210
Kernel_Killer is on a distinguished road
I know this is under PHP, but here's the CGI script I use for uploading. Fairly simple.

Code:
#!/usr/bin/perl -w

use CGI;

$upload_dir = "/usr/local/www/files/upload";

$query = new CGI;

$filename = $query->param("photo");
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("photo");

open UPLOADFILE, ">$upload_dir/$filename";

while ( <$upload_filehandle> )
 {
   print UPLOADFILE;
 }

close UPLOADFILE;

print $query->header ( );
print <<END_HTML;

<HTML>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>
<BODY>
<P>Uploaded file</P>
<br><br>
<a href="/files/index.html">Upload Another</a><br>
<a href="/files/upload">See Files</a><br>
</BODY>
</HTML>

END_HTML
__________________
Network Synapse
Screaming Electron
Kernel_Killer is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible to prevent images in a page from caching? Epsilon HTML, XML, Javascript, AJAX 2 09-06-2004 01:58 AM
New images reaffirm planet is lord of rings redhead Code Newbie News 0 07-05-2004 12:56 AM
When Uploading an image .. Can you rename with a space? sde PHP 6 08-11-2003 09:02 PM
showing images in different resolutions Hrqls HTML, XML, Javascript, AJAX 2 10-27-2002 10:59 AM


All times are GMT -8. The time now is 10:33 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting