473,434 Members | 1,494 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,434 software developers and data experts.

How to setup a Browse to Upload a Picture filed in a form?

I want to place a browse... to upload a picture form on my website. I got everything I need from here

http://www.w3schools.com/php/php_file_upload.asp

But I am having problem with the upload process. I have placed all three pages necessary on my server. Even named a folder "upload" within the server. But when I upload and run the test the file doesn't get uploaded correctly to my server. No image is in my upload folder. What do I need to do to make it work? I

http://www.w3schools.com/php/php_file_upload.asp

It's a two to three part page code. It's located here on this link on the W3 Schools website. I would post what code I have, but I know the admins don't like it when you plain copy and paste the code. I never knew how to paste it correctly within the post.

here is the file save code I have so far.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if ((($_FILES["file"]["type"] == "image/gif")
  3. || ($_FILES["file"]["type"] == "image/jpeg")
  4. || ($_FILES["file"]["type"] == "image/pjpeg"))
  5. && ($_FILES["file"]["size"] < 100000))
  6.   {
  7.   if ($_FILES["file"]["error"] > 0)
  8.     {
  9.     echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  10.     }
  11.   else
  12.     {
  13.     echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  14.     echo "Type: " . $_FILES["file"]["type"] . "<br />";
  15.     echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  16.     echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
  17.  
  18.     if (file_exists("http://www.penciledmemories.com/upload/" . $_FILES["file"]["name"]))
  19.       {
  20.       echo $_FILES["file"]["name"] . " already exists. ";
  21.       }
  22.     else
  23.       {
  24.       move_uploaded_file($_FILES["file"]["tmp_name"],
  25.       "upload/" . $_FILES["file"]["name"]);
  26.       echo "Stored in: " . "http://www.penciledmemories.com/upload/" . $_FILES["file"]["name"];
  27.       }
  28.     }
  29.   }
  30. else
  31.   {
  32.   echo "Invalid file";
  33.   }
  34. ?>
the upload form can be found at http://www.penciledmemories.com/orderformbrowsere.html
Jan 7 '11 #1
4 3977
AutumnsDecay
170 100+
Are you sure you have permissions set on the upload folder?

Folders have what's known as 'CHMOD' permissions that control access to the folder from different user groups. If you're trying to run a script (public user group) but don't have the folder's permissions to allow 'WRITE' from 'PUBLIC / EVERYONE', it won't successfully upload.

I tested it just now and I don't get a PHP error saying 'Permission Denied', so it may not be the issue, but it's worth a double check.
Jan 7 '11 #2
Ok, how would I set the permissions to work? I didn't get that error either. But when I attempt to upload an image, it just doesn't appear in the folder I named "upload" on my server. Reason I created a folder named upload was because thats where W3's code defaulted to, thought it would make things easier. They link directly to /upload. I tried both to direct link to /upload and to http://www.mywebsite.com/upload, for some reason both seemed to have failed.
Jan 7 '11 #3
AutumnsDecay
170 100+
If you have FTP access to the directory, right click on the folder and click Properties (this will change depending on what FTP client you have).

Once you're at the permissions window, set the folder to 777, which is everyone able to do anything with the folder and its contents. If there is no numeric value, just put a checkmark into every box (if there are check boxes).
Jan 7 '11 #4
Ok, I will try that. Thanks
Jan 8 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tim218 | last post by:
Hi Everyone This is my first day with PHP and, not surprisingly, I've run into a problem :-) I want to allow file uploads to the server without exposing the non-technical end-users to FTP...
1
by: The Clansman | last post by:
Hi, I have a upload picture procedure that works ok, but when the upload is done and the user press CTRL+R, the picture is uploaded again! how do I prevent it? thanks
3
by: Tim_Mac | last post by:
hi, i have a master page, and i want to put an asp:literal control in the <head><title> section. but it won't build because it says it's an unrecognized tag prefix. if i put the control inside...
6
by: Dan | last post by:
Hi again, I tried to create a second server-form in an aspx file, but there can be only one. Independantley of it's useful or not, why is it so? And why can't i create a form directly in...
0
by: @ndr01d | last post by:
I have an input formview server form that I need to also submit to a host supplied asp page that will email it. Seems so simple to me yet I am not finding it that way. Is this really that...
1
by: John Wolff | last post by:
I’m trying to upload a file to a Web Service. I have to submit the file using a standard HTML form with the <input type=“file” /tag. Ultimately, we are submitting the file from a Flash 8...
5
by: jason.tadeo | last post by:
I was wondering if anyone does any uploading picture scripts or how to do it where i could upload a picture and use php to change the picture size to what i want it to be. Anyone know where i could...
6
by: priyakollu | last post by:
hi guyz!, im using win xp, xampp version 2.5 Requirement: Upload resume from form and store in database and this would be "register.html" file later i want to retrieve that resume from database...
16
ribbo
by: ribbo | last post by:
What I need in a nutshell is a form that will allow me to upload multiple pictures (say 5) to my server while at the same time saving the names to the MySQL database. I would prefer it if the image...
8
johngault
by: johngault | last post by:
I've been working with this PHP page for several days now and I'm stumped. The page is supposed to allow the user to upload up to six images for their profile. When the user adds an image it (the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.