


How to obtain the path for uploading images in PHP and assign values to form fields
The example in this article describes how to obtain the path for uploading images in PHP and assign values to form fields. Share it with everyone for your reference, as follows:
1. Example of calling method:
Large image path:
<input type="text" name="bigImageURL" value=""> <iframe src="uppic.php?id=bigImageURL" width="600" height="25" frameborder="0" scrolling="no"></iframe>
Small image path:
<input type="text" name="smallImageURL" value=""> <iframe src="uppic.php?id=smallImageURL" width="600" height="25" frameborder="0" scrolling="no"></iframe>
2. uppic.php
<?php header("Content-Type:text/html;charset=GB2312"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"> <HTML xmlns="http://www.w3.org/1999/xhtml"> <HEAD> <TITLE>图片上传</TITLE> <META http-equiv=Content-Type c name=GENERATOR> <style type="text/css"> <!-- input{border-width:1px;border:1px solid #bdbcbd;padding:3px 0 3px 5px;} .inputbut{padding-left:3px;padding-right:2px;border:1px solid #bdbcbd;background:#FFF url(../images/inputbut_bg.gif) left center repeat-x;font-size:12px;height:24px;} --> </style> </HEAD> <BODY leftmargin=0 topmargin=0> <?php $id=$_GET["id"]; //echo "id==".$id; switch($_GET["action"]) { case "up": upmovie($id); break; default: upinput($id); break; } function upinput($id){ ?> <SCRIPT language=javascript> function check() { var strFileName=document.form.strPhoto.value; if (strFileName=="") { alert("请选择要上传的文件"); document.form.strPhoto.focus(); return false; } return true; } </SCRIPT> <form action="uppic.php?action=up&id=<?=$id?>" enctype="multipart/form-data" name="form" method="post" type="file" size="40"> <input type="submit" name="Submit" value="上 传" class=inputbut /> </form> </BODY> <?php } function upmovie($id){ global $web_picdir; $savePath=dirname(__FILE__)."/".$web_picdir; $str = date('YmdHis'); if($_FILES['strPhoto']['name']!='') { $tmp_file=$_FILES['strPhoto']['tmp_name']; $file_types=explode(".",$_FILES['strPhoto']['name']); $file_type=$file_types[count($file_types)-1]; if(strtolower($file_type)!="jpg"&strtolower($file_type)!="gif"&strtolower($file_type)!="bmp"&strtolower($file_type)!="png"){ echo "<span style=/"color:red;line-height: 25px;/">格式错误请重新上传<a href=# /a></span>"; exit; } $file_name=$str.".".$file_type; if(!copy($tmp_file,$savePath.$file_name)){ echo "<span style=/"color:red;line-height: 25px;/">上传错误请重试!!<a href=# /a></span>"; }else{ //echo "<span style=/"olor:red;line-height: 25px;/">上传成功</span><script>parent.document.getElementById(/"bigImageURL/").value=/"".$file_name."/"</script>"; echo "<span style=/"olor:red;line-height: 25px;/">上传成功</span><script>parent.document.getElementById(/"{$id}/").value=/"".$file_name."/"</script>"; echo "<a href=# /a>"; } }else{ echo "<span style=/"color:red;line-height: 25px;/">请选择需要上传的文件<a href=# /a></span>"; } } ?>
Note: Different text boxes need to define ids, iframe url: uppic.php?id=text box id
Readers who are interested in more content related to PHP image operations can check out this site's special topic: "Summary of PHP graphics and image operation skills" 》
I hope this article will be helpful to everyone in PHP programming.
The above introduces the method of obtaining the path for uploading images in PHP and assigning values to form fields, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Use Java's File.length() function to get the size of a file. File size is a very common requirement when dealing with file operations. Java provides a very convenient way to get the size of a file, that is, using the length() method of the File class. . This article will introduce how to use this method to get the size of a file and give corresponding code examples. First, we need to create a File object to represent the file we want to get the size of. Here is how to create a File object: Filef

How to convert php blob to file: 1. Create a php sample file; 2. Through "function blobToFile(blob) {return new File([blob], 'screenshot.png', { type: 'image/jpeg' })} ” method can be used to convert Blob to File.

To learn more about open source, please visit: 51CTO Hongmeng Developer Community https://ost.51cto.com Running environment DAYU200:4.0.10.16SDK: 4.0.10.15IDE: 4.0.600 1. To create an application, click File- >newFile->CreateProgect. Select template: [OpenHarmony] EmptyAbility: Fill in the project name, shici, application package name com.nut.shici, and application storage location XXX (no Chinese, special characters, or spaces). CompileSDK10, Model: Stage. Device

Use Java's File.renameTo() function to rename files. In Java programming, we often need to rename files. Java provides the File class to handle file operations, and its renameTo() function can easily rename files. This article will introduce how to use Java's File.renameTo() function to rename files and provide corresponding code examples. The File.renameTo() function is a method of the File class.

An error occurs when ubuntu mounts a mobile hard disk: mount: unknownfilesystemtype'exfat'. The processing method is as follows: Ubuntu13.10 or install exfat-fuse: sudoapt-getinstallexfat-fuseUbuntu13.04 or below sudoapt-add-repositoryppa:relan/exfatsudoapt-getupdatesudoapt-getinstallfuse- exfatCentOS Linux mount exfat format USB disk error solution to load extfa in CentOS

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Use java's File.getParent() function to get the parent path of a file. In Java programming, we often need to operate files and folders. Sometimes, we need to get the parent path of a file, which is the path of the folder where the file is located. Java's File class provides the getParent() method to obtain the parent path of a file or folder. The File class is Java's abstract representation of files and folders. It provides a series of methods for operating files and folders. Among them, get
