但是今天我说让我们进行下一步,这将是服务器的映像.我已经在YouTube上观看了3个视频,大概是对代码进行配音并以多种不同的方式尝试过100次.http://www.youtube.com/watch?v=CxY3FR9doHIhttp://www.youtube.com/watch?v=vFZfJZ_WNC4&feature=relmfu,但仍然无法获得它.但是长话短说:我有一个连接到服务器的config.php文件,这是我在上传表单页面上运行的代码:<html> <head> <title>Upload an image</title> </head><body> <form action="UploadContent.php" method="POST" enctype="multipart/form-data"> File: <input type="file" name="image"> <input type="submit" value="Upload"> </form><?php// connect to databaseinclude"config.php";// file properties$file = $_FILES['image']['tmp_name'];if (!isset($file)) echo "Please select a profile pic";else{ $image = addslashes(file_get_content($_FILES['image']['tmp_name'])); $image_name = addslashes($FILES['image']['name']); $image_size = getimagesize($_FILES['image']['tmp_name']); if ($image_size==FALSE) echo "That isn't a image."; else { $insert = mysql_query("INSERT INTO content VALUES ('','','','','','','','','','$image_name','$image',)"); }}?> </body></html>在插入行上所有'', '', '', ''的原因是因为我在第10个字段中有名称,在第11个字段中有图像blob,所有导致该名称的都是名字,姓氏和诸如此类的随机内容那.我怎样才能解决这个问题?它返回错误: 致命错误:在第22行的/home/content/34/9587634/html/WEBPAGE/UploadContent.php中调用未定义的函数file_get_content()我不知道该怎么办.解决方案该代码忽略了调用函数move_uploaded_file()的功能,该功能将检查所指示的文件是否对上载有效.您可能希望在以下位置查看一个简单的示例: http://www.w3schools.com/php/php_file_upload.asp Alright I have way to much time invested in this. I am new to PHP programming and trying to grasp the basics, but I am a little lost as of last night I was able to get a PHP form to upload basic data like a name address and stuff to my (MySQL) server.But today I said let's do the next step which would be an image to the server.I have watched 3 videos on YouTube probably a 100 times just recoping code and trying it in so many different ways.http://www.youtube.com/watch?v=CxY3FR9doHIhttp://www.youtube.com/watch?v=vFZfJZ_WNC4&feature=relmfuand still haven't been able to get it.But long story short: I have a config.php file that connects to the server and here is the the code I'm running on the upload form page:<html> <head> <title>Upload an image</title> </head><body> <form action="UploadContent.php" method="POST" enctype="multipart/form-data"> File: <input type="file" name="image"> <input type="submit" value="Upload"> </form><?php// connect to databaseinclude"config.php";// file properties$file = $_FILES['image']['tmp_name'];if (!isset($file)) echo "Please select a profile pic";else{ $image = addslashes(file_get_content($_FILES['image']['tmp_name'])); $image_name = addslashes($FILES['image']['name']); $image_size = getimagesize($_FILES['image']['tmp_name']); if ($image_size==FALSE) echo "That isn't a image."; else { $insert = mysql_query("INSERT INTO content VALUES ('','','','','','','','','','$image_name','$image',)"); }}?> </body></html>The reason for all the '', '', '', '' on the insert line is because I have the name in the 10th field and the image blob in the 11th and all the ones leading up to that are first name, last name and random stuff like that. How can I fix this? It is returning the error: Fatal error: Call to undefined function file_get_content() in /home/content/34/9587634/html/WEBPAGE/UploadContent.php on line 22I don't know what to do. 解决方案 The code overlooks calling the function move_uploaded_file() which would check whether the indicated file is valid for uploading.You may wish to review a simple example at:http://www.w3schools.com/php/php_file_upload.asp 这篇关于PHP上传图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-31 06:09