473,545 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re basic file upload form

I would like to create a very basic file upload add image form to add
to my web site and to keep them in a "tmp" directory within my web
hosting file manager once uploaded.
I understand the basic html for the form and the basic php scripting
but the fine details ie method post etc needs help also at this stage
I dont want to involve mysql data base. were should I start.
Jul 17 '05 #1
15 3190
Simon wrote:
I would like to create a very basic file upload add image form to add
to my web site and to keep them in a "tmp" directory within my web
hosting file manager once uploaded.
I understand the basic html for the form and the basic php scripting
but the fine details ie method post etc needs help also at this stage
I dont want to involve mysql data base. were should I start.


If you've not already done so, read

http://www.php.net/manual/en/features.file-upload.php

--
Jock
Jul 17 '05 #2
In article <5b************ **************@ posting.google. com>, Simon wrote:
I would like to create a very basic file upload add image form to add
to my web site and to keep them in a "tmp" directory within my web
hosting file manager once uploaded.
I understand the basic html for the form and the basic php scripting
but the fine details ie method post etc needs help also at this stage
I dont want to involve mysql data base. were should I start.


Start at the source. http://www.php.net/manual

--
http://home.mysth.be/~timvw
Jul 17 '05 #3
John Dunlop <us*********@jo hn.dunlop.name> wrote in message news:<MP******* *************** **@News.Individ ual.NET>...
Simon wrote:
I would like to create a very basic file upload add image form to add
to my web site and to keep them in a "tmp" directory within my web
hosting file manager once uploaded.
I understand the basic html for the form and the basic php scripting
but the fine details ie method post etc needs help also at this stage
I dont want to involve mysql data base. were should I start.


If you've not already done so, read

http://www.php.net/manual/en/features.file-upload.php


thanks for your reply .
I have read the online manual you recommend Its all there I have to
say the problem is I cant get any of the scripts to work Copy paste
the scripts to my files but nothing ,I have an error log that recieves
the errors so somthing is working parse errors on various lines but I
cant de bug the script I am hosting with yahoo who provide all the
configurations but no support for the actual programing. I will study
the pages you provided . But I feel there is somthing basic missing in
my attempts.
Jul 17 '05 #4
Simon wrote:

[About <http://www.php.net/manual/en/features.file-upload.php>:]
Copy paste the scripts to my files but nothing ,I have an error log
that recieves the errors so somthing is working parse errors on various
lines but I cant de bug the script


Whittle down a basic file upload script to a couple of lines. Then,
if problems persist, post it here.

--
Jock
Jul 17 '05 #5
John Dunlop <us*********@jo hn.dunlop.name> wrote in message news:<MP******* *************** **@News.Individ ual.NET>...
Simon wrote:

[About <http://www.php.net/manual/en/features.file-upload.php>:]
Copy paste the scripts to my files but nothing ,I have an error log
that recieves the errors so somthing is working parse errors on various
lines but I cant de bug the script


Whittle down a basic file upload script to a couple of lines. Then,
if problems persist, post it here.


will post a basic script that I am trying to use.
simon
Jul 17 '05 #6
John Dunlop <us*********@jo hn.dunlop.name> wrote in message news:<MP******* *************** **@News.Individ ual.NET>...
Simon wrote:

[About <http://www.php.net/manual/en/features.file-upload.php>:]
Copy paste the scripts to my files but nothing ,I have an error log
that recieves the errors so somthing is working parse errors on various
lines but I cant de bug the script


Whittle down a basic file upload script to a couple of lines. Then,
if problems persist, post it here.


This is the script I am trying to use for yahoo web hosting.
The first thing is does the html and php go on the same file as a .php
file or two seperate files.

------------------------------------------------------------------------
<body>
<form action="upload. php" method="post" ENCTYPE="multip art/form-data">
**Filename: <input type="text" size=40 name="filename" ><br>
**<input type="file" size=40 name="file"><br >
**<input type="hidden" name="MAX_FILE_ SIZE" value="10000000 00">
**<input type="submit" value="******** *************** ***********Uplo ad
*************** *************** ***">
</form>
<?php
if*($file*==*"" *||*$file*==*"n one")*{
**print*"You must specify a file to upload.<p><i>Yo u need a
<b>/tmp</b> directory for uploads to work.</i><p>";
}
else*{
**$newfile*=*"/php/tmp/$filename";
**echo*"Uploade d*as:*$newfile< br>";
**//unlink($file);
}
?>
<hr>
</body>
Jul 17 '05 #7
Simon wrote:
The first thing is does the html and php go on the same file as a .php
file or two seperate files.
Up to you.

[ ... ]
**Filename: <input type="text" size=40 name="filename" ><br>
What's this for? You've already got:
**<input type="file" size=40 name="file"><br >
which allows the user to select files.
**<input type="hidden" name="MAX_FILE_ SIZE" value="10000000 00">
Mostly useless.
**<input type="submit" value="******** *************** ***********Uplo ad
*************** *************** ***">
Browsers might ignore that leading and trailing whitespace. Got a
good reason for including it? If not, remove it.
</form>
<?php
if*($file*==*"" *||*$file*==*"n one")*{


You didn't copy 'n paste this from the Manual, did you?

http://www.php.net/manual/en/features.file-upload.php

--
Jock
Jul 17 '05 #8
John Dunlop <us*********@jo hn.dunlop.name> wrote in message news:<MP******* *************** **@News.Individ ual.NET>...
Simon wrote:
The first thing is does the html and php go on the same file as a .php
file or two seperate files.


Up to you.

[ ... ]
**Filename: <input type="text" size=40 name="filename" ><br>


What's this for? You've already got:
**<input type="file" size=40 name="file"><br >


which allows the user to select files.
**<input type="hidden" name="MAX_FILE_ SIZE" value="10000000 00">


Mostly useless.
**<input type="submit" value="******** *************** ***********Uplo ad
*************** *************** ***">


Browsers might ignore that leading and trailing whitespace. Got a
good reason for including it? If not, remove it.
</form>
<?php
if*($file*==*"" *||*$file*==*"n one")*{


You didn't copy 'n paste this from the Manual, did you?

http://www.php.net/manual/en/features.file-upload.php

Hi Jock

im sorry about that I posted the wrong script. I hope you dont mind
helping with this Ill post the sript from the manual .
<form enctype="multip art/form-data" action="_URL_" method="post">
<input type="hidden" name="MAX_FILE_ SIZE" value="30000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>

<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILE S should be used
instead
// of $_FILES.

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];

print "<pre>";
if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile))
{
** print "File is valid, and was successfully uploaded. ";
** print "Here's some more debugging info:\n";
** print_r($_FILES );
} else {
** print "Possible file upload attack!* Here's some debugging
info:\n";
** print_r($_FILES );
}
print "</pre>";

?>
This is the script and form we can work on if you dont mind
I have tried this however nothing appears to find its way to my tmp
directory. can we wittle this down to the bare script.

1 I have checked file uploads are allowed and enabled
2 php is installed on my server yahoo web hosting
3 the html form appears and works a file is selected from the local
disc.
4 press upload and thats it .
5 nothing appears in my tmp directory.

could you script this so it is on one php file only.

Regards
Simon
Jul 17 '05 #9
Simon wrote:

[ ... ]
1 I have checked file uploads are allowed and enabled
2 php is installed on my server yahoo web hosting
3 the html form appears and works a file is selected from the local
disc.
4 press upload and thats it .
5 nothing appears in my tmp directory.


Stick "error_reportin g(E_ALL);" at the start of your script.

--
Jock
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3911
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give them a caption, storing the caption and filename in a text file. It's a bit buggy when removing the photos and captions from the file, and also in...
13
4285
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming that this is suppossed to end up as a component for others to use, and therefore I do NOT have access to their global.cs::Session_End() how do I...
2
3421
by: mark | last post by:
How do I detect that a particular form element is a file upload or if the file upload has worked? In the Python cgi module documentation I found suggested code... form = cgi.FieldStorage() fileitem = form if fileitem.file: # It's an uploaded file; count lines
7
3171
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file" name="file_1" size=46 /><input type=submit /> so, after adding a few files, the input fields look like this:
3
1778
by: MarkusJNZ | last post by:
Hi, does anyone know of a good (Preferably free but don't mind paying some $$ for source code) basic document sharing application? Basically, a single admin should be able to upload files to a folder and then say "these users have access to the file that was uploaded" and specify what users can access the file. I would like .NET 1.1 or...
1
2713
by: pbd22 | last post by:
hi. i have been posting this here and elsewhere a lot and can't seem to get resolution on this problem. i have been trying to upload files using a hidden iframe to a asp.net/vb.net form. the problem is that the server code can't read the httpfilecollection. the count is always zero. my upload form's form tag looks like this:
2
7634
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but don't have any luck is to do a form validation. This script requires the files: db-file-to-disk.asp and _upload.asp. There is a DESCRIPTION field in...
1
5440
by: chrisj | last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully. In this modified version there are two groups that use this upload script. Members of one group get automatically re-directed after uploading. However, this member group never gets the benefit of knowing if they've uploaded an incorrect...
6
3821
Jacotheron
by: Jacotheron | last post by:
I need a PHP script that can upload music files (mp3). The script is for a home project I have started a while ago. I have a MySQL database of all the music that I have. Other computers on the network should be able to connect to the database and run queries on the database or upload new music that does not yet exist on the database. The uploaded...
0
7401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7757
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5329
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.