473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

q. Script to allow users to upload photos

I am trying to create a php script to allows users to upload photos:

The first file looks like this:

<html>

<head>

<title>Upload Photo</title>

</head>

<body>

<BODY LINK="#0000ff" VLINK="#800080" BACKGROUND="./wall.jpg">

<br>

<Font Size =4/><B/>Upload Photo For Teacher Card: <br><br><br></Font Size
=4>

<form action="UploadPhoto2.php" enctype="multipart/form-data" method="POST">

<input type="hidden" name="MAX_FILE_SIZE" value="51200">

File to Upload: <input type="file" name="fileupload"><br><br>

<input type="submit" value="Upload!">

</form>

</body>

</html>

It calls the second file that looks like this:

<html>

<head>

<title>Listing 9.14 A file upload script</title>

</head>

<body>

<h1>File had been uploaded successfully</h1>

<br>

<br>

</FONT><P><P ALIGN="LEFT"></FONT>&nbsp;&nbsp;&nbsp;&nbsp;<A
HREF="http://www.teachercards.org"><FONT SIZE=3>Return Home</FONT></A></P>

<?php

$file_dir = "/uploads"; set up this directory wanting photos would be
uploaded here and it is not working.

foreach($_FILES as $file_name => $file_array) {

print "path: ".$file_array['tmp_name']."<br>\n";

print "name: ".$file_array['name']."<br>\n";

print "type: ".$file_array['type']."<br>\n";

print "size: ".$file_array['size']."<br>\n";

if (is_uploaded_file($file_array['tmp_name'])) {

move_uploaded_file($file_array['tmp_name'],
"$file_dir/$file_array[name]") or die ("Couldn't copy");

print "file was moved!<br><br>";

}

}

?>

</html>

I am pretty sure the problem is in the second file and the code just needs
to be made more specific to my web site. But not sure how to do it and
would appreciate some help.

TIA

David
Jul 17 '05 #1
1 2709
look at the gallery script on sourceforge
(http://sourceforge.net/projects/sphp) for some ideas and hints ...
it's a bit more developed, but it still sticks to basics (no db)

Jul 17 '05 #2

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

Similar topics

0
by: mandr | last post by:
Bonjour , j'ai un petit pb sur mon script suivant : <?php // Ouverture de la session session_start();
1
by: leigh | last post by:
I need a php photo gallery script that will allow me to categorise photos to directories/sections, post captions for each photo and allow users to comment on individual photos. If there is one...
4
by: Lee Marsh | last post by:
Okay, I posted this over at alt.php, but got nil response, so I'm posting it hear again in hopes of getting a response. Sorry to anyone reading this twice: Okay...so on my website, where people...
1
by: Throw | last post by:
G'day everyone I'm looking for a simple photo gallery script in PHP (or Perl), but not too simple. I have tried several photo gallery scripts in either language and I have found that they are...
2
by: attenborough | last post by:
Hi, am hoping that someone may be able to help me. Im designing a small website using PHP and MySQL. I would like to allow my visitors to upload a photo via a form on it. Im worried that people...
4
by: Jim Michaels | last post by:
after a file upload, $_FILES is not populated but $_POST is. what's going on here? $_POST=C $_POST=C $_POST=C $_POST=C:\\www\\jimm\\images\\bg1.jpg $_FILES= $_FILES= $_FILES=
3
by: K. | last post by:
Hello! I would like to create php code for uploading photos into the server. However, it would not be so easy script to create. I would like to upload unlimited number of photos into the ftp...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.