Free Web Hosting Forum
(#1 (permalink))
Old
Junior Member
nanoenzagaray is on a distinguished road
 
Posts: 2
Join Date: Oct 2008
Default Upload script error - 10-15-2008, 07:03 PM

Hi, i have this script for upload pictures. the script says thats the upload has been done ok but when i look for the file, it isnt there. here is the code, plese tellme if theres something rong. Thanks!

$nombre="/public_html/imagenes/img/";
$permitidos=array("gif","jpeg","jpg");
$ext=array_pop(explode(".",$nombre));
if (in_array($ext, $permitidos)){
if (!file_exists($nombre)){
@move_uploaded_file($_FILES['examinar']['tmp_name'], $nombre.$_FILES['examinar']['name']);
header("Location: ./U.php?d=".$nombre);
}else{
echo "La imagen ya existe";
}
}else{
echo "Tipo de archivo no permitido";
}
Reply With Quote
(#2 (permalink))
Old
Member
moofang is on a distinguished road
 
Posts: 32
Join Date: Aug 2008
Default 10-18-2008, 03:41 AM

The script looks fine on quick glance. A few things you could probably check :

- does "/public_html/imagenes/img/" exist and does it have the right permissions?
- check the return value of move_uploaded_file and see if it is failing
- print_r $_FILES and see if there was a problem with the uploading itself
Reply With Quote
(#3 (permalink))
Old
Junior Member
nanoenzagaray is on a distinguished road
 
Posts: 2
Join Date: Oct 2008
Default Thats it! - 10-18-2008, 05:50 PM

It was a permissions problem, i changed them and its works perfect. Thanks!
Reply With Quote
(#4 (permalink))
Old
Junior Member
duniadamay is on a distinguished road
 
Posts: 4
Join Date: Oct 2008
Default 10-25-2008, 11:11 AM

Hai,

Nice to read your post cause I have the same problem...
I want to ask about 'How can I change my permission'???

Thank you...
Reply With Quote
(#5 (permalink))
Old
Junior Member
duniadamay is on a distinguished road
 
Posts: 4
Join Date: Oct 2008
Default 10-25-2008, 11:21 AM

$realfilename = $_FILES['gambar']['name'];
$aFileNameParts = explode(".", $realfilename);
$sFileExtension = end($aFileNameParts);
$nPhotoSize = $_FILES['gambar']['size'];

if ($nPhotoSize == 0) {
echo "<br/><center>There is no picture";
echo "<br />Empty file!</center>";
}
else
if ($sFileExtension != "jpg" && $sFileExtension != "JPEG" && $sFileExtension != "JPG" && $sFileExtension != "gif" && $sFileExtension != "GIF") {
echo "<center><br/>JPG and GIF!</center>";
}

else
if ($nPhotoSize > 300000) {
echo "<center><br/>300 kb</center>";
}

else {

$temp = $_FILES['gambar']['tmp_name'];
$error = $_FILES['gambar']['error'];
$uploaddir = "../komentar/";
$realfilename = str_replace(" ", "", $realfilename);
$uploadfile = copy($temp, $uploaddir.$realfilename);

if (!empty($_POST[nama]) AND !empty($_POST[telepon]) AND !empty($_POST[email]) AND !empty($_POST[komentar])) {
$perintahsql = "insert into komentar values
('','$tanggal','$jam','$_POST[nama]','$_POST[alamat]','$_POST[telepon]','$_POST[email]','$_POST[komentar]','".$realfilename."')";
mysql_query($perintahsql);
echo "<center><br/>[ <a href='lihatkomentar.php'>OK</a> ]";
}
}
?>


"Warning: copy(../komentar/Winter.jpg) [function.copy]: failed to open stream: Permission denied"


that my code....
Reply With Quote
(#6 (permalink))
Old
Senior Member
s.j.hebert is on a distinguished road
 
Posts: 247
Join Date: Aug 2008
Default 10-25-2008, 02:18 PM

duniadamy, in your case the problem is the filesyste permissions on the folder ../komentar/. You need to either use an FTP client or the file manager in cPanel to change the permissions of this filder to 777


This signature is not part of the response. However it does contain important information worth reading
Search FAQ
How to ask a question
Please don't add a new, unrelated question to an existing thread! For new questions, start a new thread. But before you do, don't forget to search- your question has probably already been answered.
Reply With Quote
(#7 (permalink))
Old
Junior Member
duniadamay is on a distinguished road
 
Posts: 4
Join Date: Oct 2008
Smile How? - 10-27-2008, 12:20 PM

Thank for your reply...

but i don't know how to change this folder permission to 777, could you tell steps to do it???
Reply With Quote
(#8 (permalink))
Old
Senior Member
s.j.hebert is on a distinguished road
 
Posts: 247
Join Date: Aug 2008
Default 10-27-2008, 05:39 PM

Go to the 'File Manager' in cPanel, navigate to the folder komentar/ and clidk the chmod button to change the permissions of this folder to 777, then click the green check mark.


This signature is not part of the response. However it does contain important information worth reading
Search FAQ
How to ask a question
Please don't add a new, unrelated question to an existing thread! For new questions, start a new thread. But before you do, don't forget to search- your question has probably already been answered.
Reply With Quote
(#9 (permalink))
Old
Junior Member
duniadamay is on a distinguished road
 
Posts: 4
Join Date: Oct 2008
Default 10-29-2008, 03:47 PM

Hey, it's work... Thank you very much Mr. S.J. Hebert...
Reply With Quote
(#10 (permalink))
Old
Junior Member
bamboo is on a distinguished road
 
Posts: 1
Join Date: Oct 2008
Default I cant upload media files. Please help. - 10-30-2008, 08:22 AM

Urmm..hello. I have a problem..i cant seem to upload media files into my website. But image files i can. Why?? I have uploaded one music file and it worked. But when i wanted to upload another music file into my website, it said:

"Internet Explorer cannot display the webpage

Most likely causes:
You are not connected to the Internet.
The website is encountering problems.
There might be a typing error in the address."


I thought it has sumthing to do with my home connection. But when i went to an internet cafe, it still is the same. Why? Does anyone can help me? Thanks alot!
Reply With Quote
Reply


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

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



Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0
vBulletin Skin developed by: vBStyles.com