473,406 Members | 2,954 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,406 software developers and data experts.

Image upload problem

Hello everybody,

Im a beginner in PHP and i'm thinking how i can make more things on my own made upload script:

Sorry if this is the wrong forum or if its not allowed to ask for script help/reqeusts.

[PHP]
<?php
if (isset($_POST['uploadedfile'])) {
if($_POST['uploadedfile'] == NULL) {
die();
}
$target_path = "images/profiles/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=profile.msnw?epuid=$regcookie\">";
} else{
echo "There was an error uploading the file, please try again!";
}

} else {
echo "
<font color=\"#064f84\" face=\"Tahoma\" size=\"2\"><b>Profile photo</b></font>
<br>
<br>
<span class=\"style10\">
<font face=\"Tahoma\" size=\"2\">
Upload your own photo to your profile, Click on browse, Select your photo and press Upload!</b>
<br><br>
<form enctype=\"multipart/form-data\" method=\"POST\" action=\"$PHP_SELF?action=dpphots\">
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"100000\" />
Choose a image to upload: <input name=\"uploadedfile\" type=\"file\" /><br /><br />
<input type=\"submit\" value=\"Upload File\" />
</form></font>
</span>
";
}
?>
[/PHP]

How can i add like file types and size limits, and reondom usernames. btw, this script is not working, Im just a beginner who wants to learn and get help.

Thanks in advance.
Mar 22 '07 #1
1 1171
ak1dnar
1,584 Expert 1GB
Try this script. I couldn't figure out the File size limit. try to do it later.

[PHP]<?php
$target_path = "1234/"; //Directory Name to Upload
if($_POST['upload'])
{
$newName = md5(basename($_FILES['upload_fle']['name']));
$ext = strrchr(basename($_FILES['upload_fle']['name']), ".");
$fullName = $newName.$ext;

if(move_uploaded_file($_FILES['upload_fle']['tmp_name'], $target_path.$fullName))
{
echo "The file ". basename( $_FILES['upload_fle']['name']).
" has been uploaded with this name : ".$fullName;
} else
{
echo "There was an error uploading the file, please try again!";
}

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form action="<? echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data" name="frmAlbum" id="frmAlbum">
<input name="upload_fle" type="file" id="upload_fle"/>
<BR>
<input name="upload" type="submit" value="Upload">
</form>
</body>
</html>
[/PHP]
Mar 22 '07 #2

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

Similar topics

15
by: lawrence | last post by:
I've been using the following function (yes, it is inelegant, what can I say, I wrote it a long time ago) to upload images. Haven't had a problem with it for at least a year, and I don't recall...
3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
0
by: Paul Hamlington | last post by:
Hello, I've been programming in ASP for a little while now and quite an advanced user, but I have come across an unusual problem in which I need assistance. I have built my own image upload,...
2
by: Gary \(Girish\) | last post by:
Hello: I am using SA-FileUp to enable members to upload their product images to my ISP sever. When member uploaded a new image file, the file name is replaced with the member ID and the old file...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
2
by: prakharv | last post by:
Hi All, Below is the code which I am using to upload a jpeg file to the server. But the problem I am facing is that it is not copying the entire contents of the image file to the webserver and it...
4
by: Muddasir | last post by:
Hi.. i am having a strange problem.......the problem is i am trying to upload a file and to store it in db....when the file got stored in db...it got converted into black and white image and...
10
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for...
1
by: sravani1 | last post by:
This code runs like when i submit the form it takes the image and displayed and top of the image a map will displayed. But actually i want that when i give the image it checks the location in the map...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
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: 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
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...
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
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,...
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: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.