Php URL for uploading images

Source: Internet
Author: User
Tags php and mysql
With PHP and MySQL to do something, with a Select the image uploaded to the database URL is the absolute path, the query out after the display, how to make a relative path (such as: Http://192.168.40.10:1500/php/www/pictures/1.jpeg), trouble explaining the details of the point, Better have a small example, I am a novice, understand less, thank you.


Reply to discussion (solution)

Upload will be pictures/1.jpeg this point in the database on the line.

Add domain name when displaying

This I know, but I do not know how to cut out 1.jpg, $_files[' myFile ' [' name '] This function I will not use, ' myFile ' and ' name ' stand for what?

Upload will be pictures/1.jpeg this point in the database on the line.

Add domain name when displaying
This I know, but I do not know how to cut out 1.jpg, $_files[' myFile ' [' name '] This function I will not use, ' myFile ' and ' name ' stand for what?

Upload will be pictures/1.jpeg this point in the database on the line.

Add domain name when displaying
I useGets the picture name, the picture name is c:/php/www/pictures/1.jpg;
I want to know what way to get fromGet the filename pictures/1.jpeg, I know should get to pictures/1.jpeg this file path, but specifically how to get I I won't, trouble can say point of detail, thank you.

form controls
After submission $_fiels[' a ' [' name '] is the name of the picture

form controls
After submission $_fiels[' file ' [' name '] is the name of the image
$_fiels[' file ' [' name '] This function I do not understand, how to use this function ah? What does file and name stand for?
$picture _cut = $_files[' picture ' [' name ']; I have no effect in writing this.

Just a frizz.

form controls
After submission $_fiels[' a ' [' name '] is the name of the picture

Just a frizz.

form controls
After submission $_fiels[' a ' [' name '] is the name of the picture
Oh, no, please help me to see if I write it right?
$id = $_post[' id '];
$barcode = $_post[' barcode ');
$goods _name = $_post[' goods_name ');
$category = $_post[' category '];
$specifications = $_post[' specifications ');
$manufacturers = $_post[' manufacturers ');
$number = $_post[' number '];
$instruction = $_post[' instruction ');
$picture = $_files[' Picture_url ' [' name '];
$url = "http://172.17.4.96:1500/pictures/";
$picture _url = $url. $picture;
if (! $id | |! $barcode | |! $goods _NAME | |! $category | |! $specifications | |! $manufacturers | |! $number
|| ! $instruction | | ! $picture _url) {
Echo ' empty! ';
Exit
}

@ $db = new mysqli (' localhost ', ' root ', ' root ', ' EC ');
if (! $db)
{
echo ' ERROR ';
Exit
}

$query = "INSERT into goods values ('". $id. "', '". $barcode. "', '". $goods _name. "', '". $category. "
$specifications. "', '". $manufacturers. "', '". $number. "', '". $instruction. "', '". $picture _url. "')";
$result = $db->query ($query);
if ($result) {
echo "";
} else {
echo "An error has occurred. The item was not added. ";
}
Mysql_close ($DB);
?>

Put your form on the list

Just a frizz.

form controls
After submission $_fiels[' a ' [' name '] is the name of the picture
The value obtained from the control should not be used with $ A = $_post[' a ']; get it, since the use of the POST method, but also how to use $_fiels[' a ' [' name '];

Put your form on the list

I don't know how you learned PHP.

I don't know how you learned PHP.
I just haven't been learning for a long time, do I have a lot of code problems?

Your form is not enctype= "Multipart/form-data"
So there is no file upload
Since it's not a file upload, there's no $_fiels.

Even if it's not on the Enctype= "Multipart/form-data."
As you did not deal with $_files[' picture_url ' [' tmp_name '], same as no upload

This post was last edited by xuzuning on 2013-03-14 13:52:07 Edit your form without enctype= "Multipart/form-data"
So there is no file upload
Since it's not a file upload, there's no $_fiels.

Even if it's not on the Enctype= "Multipart/form-data."
Because you do not have to $_files[' picture_url ' [' tmp_name '] place ...
I understand, I used the wrong way, I do not want to upload files, just want to passThe URL of the picture to the database, but now the problem is the upload is an absolute path, taken out after the page is not displayed, my idea is to upload an absolute path (such as: c:/php/wwww/pictures/1.jpg) before the URL truncation only upload picture/1. JPG, then query it out with path, so it can be displayed, but I don't know how to truncate this absolute path and leave what I want.

$s = ' c:/php/wwww/pictures/1.jpg '; $p = basename (dirname ($s)). ' /'. basename ($s); Echo $p;
Pictures/1.jpg

PHP Code
?



123

$s = ' c:/php/wwww/pictures/1.jpg '; $p = basename (dirname ($s)). ' /'. basename ($s); echo $p;p ictures/1.jpg
Thanks, it works. I am now self-taught, so not very system, you have any good book or good way to recommend it, thank you.

PHP Code
?



123

$s = ' c:/php/wwww/pictures/1.jpg '; $p = basename (dirname ($s)). ' /'. basename ($s); echo $p;p ictures/1.jpg

CSDN so many medals for the Ashes players, CSDN and you have a relationship?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.