php upload images???
- Started
- Last post
- 22 Responses
- georgietexan
I have a script to uplaod data into mysql database works great. I would also like to upload at image to a folder and link it to my page you anyone of you have the upload script for an images?
- ********0
- georgietexan0
does anyone have a quick script? I keep getting errors. with code I have.
- georgietexan0
I get errors...
<?
include("/includes/connection.php");
echo "";
echo "local temp file called after upload: $uploadfile
";
echo "original remote file called: $uploadfile_name
";
echo "size of the of the file in bytes: $uploadfile_size
";
echo "file type: $uploadfile_type
";
echo "";
echo "";if ( $uploadfile == "none" ) {
echo "No file was uploaded";
echo "Back to the form to upload files";
exit;
}if ($uploadfile_size < 30072 ) {
if (copy($uploadfile,"www/mydot.com/docs/$uploadfile_name"))
{
echo "File Uploaded OK ";
unlink($uploadfile);
} else {
echo "File Upload Failed";
}} else {
echo "Sorry files need to be less than 3KB for uploading";
}
?>
Back to the form to upload files
- ********0
you chmod the directory your trying t upload to?
- georgietexan0
777 write to folder
- georgietexan0
error:
Warning: Unable to open '' for reading: No such file or directory in /home/virtual/site287/fst/var/ww... on line 27
File Upload Failed Back to the form to upload
- tobor0
Make sure you have the right directory listing.
Check where your folder is in php, with the phpinfo(); function.-------------------
<?php
echo ini_set('upload_max_filesize', '41943040')."
";
echo ini_set('post_max_size', '40MB')."
";
echo ini_set('max_execution_time', '720');$file_dir="/home/virtual/site300/fst/var/subdomain/webmaster/html/uploader/holder";
$file_url="http://www.your-site.com/uploader/holder";foreach ( $HTTP_POST_FILES as $file_name => $file_array ) {
$proper_name = $project."/".$file_array['name...
print "path: ".$file_array['tmp_name']."
";$msg = $email_message."
";
$msg .= "A file has been uploaded here:
$file_url/$proper_name
Regarding project $project.";
$msg .= "Statistical info regarding file:
";
$msg .= "-------------------------------...
";
$msg .= "name: ".$file_array['name']."
";
$msg .= "type: ".$file_array['type']."
";
$msg .= "size: ".$file_array['size']."bytes
";$return_print = "";
if ( is_uploaded_file( $file_array['tmp_name']) ) {
move_uploaded_file( $file_array['tmp_name'], "$file_dir/$proper_name")
or die ($return_print .= "Couldn't Upload file");
$return_print .= "File Uploaded Successfully.";
}
}print $return_print;
?>
- georgietexan0
ok did the check looks good. under HTTP_SERVER_VARS["PATH_TRANSLATE...
- georgietexan0
Sorry but I'm about to lose it I have been working on this for two days. All I want to do is use php to upload images (jpgs) to a folder on my server. Now I have been using php for a year or two to do simple things like this but now I'm at a loss. I can email the script to anyone that wants to look it over. I have chomd 777 the file so now I can find the reason I can't write this file to my folder. Do any of you have a script or anything to help?
- instantok0
if you go to http://www.hotscripts.com and search for uploaders or image galleries you will find more than a few options that do exactly what you want and many come nicely commented...some even with installers...not as gratifying as doing it yourself...but why reinvent the wheel?
- unknown0
I have a very easy cgi script if thats any use, works great for me.
- georgietexan0
rasko thanks but I have not touch CGI stuff it's might confuse me even more. or not send it to my email.
I'll also try hotscripts an yes I would like to learn how it works step by step I haven't use an installer yet and really don't think I should for something so simple. i'm starting to think I don't have something setup right with my php.inc or something? sorry I guess I'm still new to this thanks for all the help
- enobrev0
well, chmod the file for 777 won't do anything for uploads, you have to chmod the directory you are uploading to to allow write permissions (777) to that directory.
- georgietexan0
O I meant chmod the directory sorry yeah so I did that too. I used phpinfo to see the path I also put the .php file in taht same directory. weird I can't see why it not working?
- enobrev0
send me the script you're using...
- georgietexan0
<?
include("/includes/connec
tion.php");
echo "";
echo "local temp file called after upload: $uploadfile
";
echo "original remote file called: $uploadfile_name
";
echo "size of the of the file in bytes: $uploadfile_size
";
echo "file type: $uploadfile_type
";
echo "";
echo "";if ( $uploadfile == "none" ) {
echo "No file was uploaded";
echo "Back to the form to upload files";
exit;
}if ($uploadfile_size
- enobrev0
email may work better
- georgietexan0
emailed.. check it out I don't think it's the code but my server config.. or my path to the folder.
- georgietexan0
emailed.. check it out I don't think it's the code but my server config.. or my path to the folder.
- unknown0
email me if you still need the script.